Submission #895266

#TimeUsernameProblemLanguageResultExecution timeMemory
895266AndreyChessboard (IZhO18_chessboard)C++14
70 / 100
282 ms4388 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,k,x,y,ans = LLONG_MAX; cin >> n >> k; vector<pair<long long,long long>> haha(0); for(long long i = 0; i < k; i++) { cin >> x >> y >> x >> y; haha.push_back({x-1,y-1}); } for(long long i = 1; i < n; i++) { if(n%i == 0) { long long br = (((n/i)*(n/i)+1)/2)*i*i; for(long long j = 0; j < k; j++) { if((haha[j].first%(2*i) < i) == (haha[j].second%(2*i) < i)) { br--; } else { br++; } } ans = min(ans,br); br = (((n/i)*(n/i))/2)*i*i; for(long long j = 0; j < k; j++) { if((haha[j].first%(2*i) < i) != (haha[j].second%(2*i) < i)) { br--; } else { br++; } } ans = min(ans,br); } } cout << ans; return 0; }
#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...