Submission #861610

#TimeUsernameProblemLanguageResultExecution timeMemory
861610PagodePaivaChessboard (IZhO18_chessboard)C++14
39 / 100
310 ms9976 KiB
#include<bits/stdc++.h> #define inf 1e18 #define int long long #define N 1010 using namespace std; int v[N][N]; int mark[N][N]; int32_t main(){ int n, k; cin >> n >> k; if(n > N-1){ int res1 = 0; int res2 = 0; int p = n; if(n % 2 == 0){ res1 = 2; res2 = 2; } else{ res1 = (p+1)/2; res2 = (p-1)/2; } for(int i = 1;i <= k;i++){ int a, b, c, d; cin >> a >> b >> c >> d; if(a % 2 != b % 2){ res1--; res2++; } else{ res1++; res2--; } } cout << min(res1, res2) << '\n'; return 0; } // vector <pair <int, int>> v; for(int i = 1;i <= k;i++){ int a, b, c, d; cin >> a >> b >> c >> d; v[a][b] = 1; } int res = inf; for(int p = 1;p < n;p++){ if(n % p != 0) continue; int resp = 0; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ int ti = (i-1)/p; int tj = (j-1)/p; if((ti % 2 )!= (tj % 2)){ if(v[i][j] != 0) resp++; } else{ if(v[i][j] != 1) resp++; } } } // cout << p << ' ' << resp << '\n'; res = min(res, resp); resp = 0; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ int ti = (i-1)/p; int tj = (j-1)/p; if((ti % 2 )!= (tj % 2)){ if(v[i][j] != 1) resp++; } else{ if(v[i][j] != 0) resp++; } } } res = min(res, resp); } cout << res << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...