-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9455.cpp
More file actions
56 lines (51 loc) · 999 Bytes
/
9455.cpp
File metadata and controls
56 lines (51 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 9455. 박스
// 2021.06.06
// 구현
#include<iostream>
#include<queue>
using namespace std;
int map[101][101];
queue<int> q;
int main()
{
int ans = 0;
int cnt = 0;
int t;
int n, m, k;
cin >> t;
while (t-- > 0)
{
ans = 0;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> map[i][j];
}
}
for (int i = 0; i < m; i++)
{
for (int j = n - 1; j >= 0; j--)
{
if (map[j][i] == 1)
{
q.push(n - j - 1);
}
}
cnt = 0;
while (!q.empty())
{
k = q.front();
q.pop();
if (cnt != k)
{
ans += k - cnt;
}
cnt++;
}
}
cout << ans << endl;
}
return 0;
}