Submission #845720

#TimeUsernameProblemLanguageResultExecution timeMemory
845720vjudge1Skandi (COCI20_skandi)C++17
9 / 110
1 ms348 KiB
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define int long long using namespace std; const int inf = 2e18 + 5; const int N = 5e3 + 5; const int mod = 998244353; int fpow(int a, int b){ if(b == 0) return 1; int p = 1; while(b){ if(b&1) p = p*a; b = b/2; a = a*a; } return p; } int32_t main(){ //freopen("in.txt","r", stdin); int n, m; cin>>n>>m; vector<vector<int> > a(n, vector<int>(m)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ char c; cin>>c; a[i][j] = c - '0'; } } int ans1 = 0, ans2 = 0; for(int i = 0; i < n; i++){ bool mask = 0; for(int j = 0; j < m; j++){ if(a[i][j] == 0 && !mask){ mask = 1; ans1++; } else if(a[i][j] == 1 && mask){ mask = 0; } } } for(int i = 0; i < m; i++){ bool mask = 0; for(int j = 0; j < n; j++){ if(a[j][i] == 0 && !mask){ mask = 1; ans2++; } else if(a[j][i] == 1 && mask){ mask = 0; } } } cout<<min(ans1, ans2)<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...