Submission #861603

#TimeUsernameProblemLanguageResultExecution timeMemory
861603PagodePaivaChessboard (IZhO18_chessboard)C++17
39 / 100
313 ms11344 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; // 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...