#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define print(a) \
for (auto x : a) \
cout << x << ' '; \
cout << endl;
#define printmp(a) \
for (auto x : a) \
cout << x.fs << ' ' << x.ss << endl;
void solve(){
int n, m;
cin >> n >> m;
vector<vector<char>> a(n, vector<char> (m));
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
cin >> a[i][j];
if(n == 1){
int r = 0, ans = 0, l = 0;
while(r < m){
while(r < m and a[0][r] == '0')
r ++;
l = r;
while(r < m and a[0][r] == '1')
r ++;
ans += (r != l);
}
cout << ans;
}
else if(m == 1){
int r = 0, ans = 0, l = 0;
while (r < n)
{
while (r < n and a[r][0] == '0')
r++;
l = r;
while (r < n and a[r][0] == '1')
r++;
ans += (r != l);
}
cout << ans;
}
else{
cout << 4 << endl;
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
// freopen("bomb.in", "r", stdin);
// freopen("bomb.out", "w", stdout);
int t = 1;
// cin >> t;
while(t --){
solve();
cout << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
17 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
28 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
29 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
30 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
32 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
33 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
34 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
35 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
36 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Incorrect |
57 ms |
6492 KB |
Output isn't correct |
39 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
40 |
Incorrect |
8 ms |
1116 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
43 |
Incorrect |
53 ms |
6744 KB |
Output isn't correct |
44 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
45 |
Incorrect |
68 ms |
6492 KB |
Output isn't correct |
46 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
47 |
Incorrect |
62 ms |
6740 KB |
Output isn't correct |
48 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
49 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
50 |
Incorrect |
66 ms |
6636 KB |
Output isn't correct |
51 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
52 |
Incorrect |
53 ms |
6632 KB |
Output isn't correct |
53 |
Incorrect |
57 ms |
6636 KB |
Output isn't correct |
54 |
Incorrect |
55 ms |
6492 KB |
Output isn't correct |
55 |
Incorrect |
57 ms |
6492 KB |
Output isn't correct |
56 |
Incorrect |
53 ms |
6636 KB |
Output isn't correct |
57 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
58 |
Incorrect |
55 ms |
6640 KB |
Output isn't correct |
59 |
Incorrect |
54 ms |
6492 KB |
Output isn't correct |
60 |
Incorrect |
59 ms |
6492 KB |
Output isn't correct |
61 |
Incorrect |
61 ms |
6488 KB |
Output isn't correct |
62 |
Incorrect |
54 ms |
6744 KB |
Output isn't correct |
63 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
64 |
Incorrect |
54 ms |
6636 KB |
Output isn't correct |
65 |
Incorrect |
58 ms |
6488 KB |
Output isn't correct |
66 |
Incorrect |
52 ms |
6632 KB |
Output isn't correct |
67 |
Incorrect |
52 ms |
6632 KB |
Output isn't correct |
68 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
69 |
Incorrect |
53 ms |
6488 KB |
Output isn't correct |
70 |
Incorrect |
34 ms |
4440 KB |
Output isn't correct |
71 |
Incorrect |
60 ms |
6632 KB |
Output isn't correct |
72 |
Incorrect |
53 ms |
6640 KB |
Output isn't correct |
73 |
Incorrect |
55 ms |
6492 KB |
Output isn't correct |
74 |
Incorrect |
55 ms |
6632 KB |
Output isn't correct |
75 |
Incorrect |
59 ms |
6492 KB |
Output isn't correct |
76 |
Incorrect |
54 ms |
6488 KB |
Output isn't correct |
77 |
Incorrect |
53 ms |
6688 KB |
Output isn't correct |
78 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
79 |
Incorrect |
66 ms |
6492 KB |
Output isn't correct |
80 |
Incorrect |
54 ms |
6492 KB |
Output isn't correct |
81 |
Incorrect |
54 ms |
6492 KB |
Output isn't correct |
82 |
Incorrect |
79 ms |
6648 KB |
Output isn't correct |
83 |
Incorrect |
53 ms |
6636 KB |
Output isn't correct |
84 |
Incorrect |
57 ms |
6492 KB |
Output isn't correct |
85 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
86 |
Incorrect |
54 ms |
6488 KB |
Output isn't correct |
87 |
Incorrect |
54 ms |
6492 KB |
Output isn't correct |
88 |
Incorrect |
57 ms |
6636 KB |
Output isn't correct |
89 |
Incorrect |
52 ms |
6488 KB |
Output isn't correct |
90 |
Incorrect |
33 ms |
4444 KB |
Output isn't correct |
91 |
Incorrect |
53 ms |
6488 KB |
Output isn't correct |
92 |
Incorrect |
52 ms |
6492 KB |
Output isn't correct |
93 |
Incorrect |
53 ms |
6488 KB |
Output isn't correct |
94 |
Incorrect |
53 ms |
6488 KB |
Output isn't correct |
95 |
Incorrect |
55 ms |
6492 KB |
Output isn't correct |
96 |
Incorrect |
53 ms |
6488 KB |
Output isn't correct |
97 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
98 |
Incorrect |
53 ms |
6492 KB |
Output isn't correct |
99 |
Incorrect |
54 ms |
6492 KB |
Output isn't correct |
100 |
Incorrect |
65 ms |
6492 KB |
Output isn't correct |