# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
855363 | Alfraganus | Bomb (IZhO17_bomb) | C++17 | 63 ms | 131072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 << 3 << 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;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |