Submission #855367

#TimeUsernameProblemLanguageResultExecution timeMemory
855367AlfraganusBomb (IZhO17_bomb)C++17
1 / 100
61 ms6744 KiB
#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 << 1 << 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; } }
#Verdict Execution timeMemoryGrader output
Fetching results...