Submission #844042

#TimeUsernameProblemLanguageResultExecution timeMemory
844042Darren0724Chessboard (IZhO18_chessboard)C++17
39 / 100
53 ms1884 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,q;cin>>n>>q; vector<int> v; vector<int> a[2]; for(int i=1;i<n;i++){ if(n%i==0){ v.push_back(i); int p=n/i; if(p&1){ a[0].push_back((p*p-1)*i*i/2); a[1].push_back((p*p+1)*i*i/2); } else{ a[0].push_back(n*n/2); a[1].push_back(n*n/2); } } } int sz=v.size(); for(int i=0;i<q;i++){ int c,d; cin>>c>>d>>c>>d; c--;d--; for(int j=0;j<sz;j++){ int k=v[j]; int c1=c/k; int d1=d/k; c1%=2; d1%=2; c1^=d1; if(c1){ a[0][j]--; a[1][j]++; } else{ a[0][j]++; a[1][j]--; } } } int ans=n*n; for(int j=0;j<sz;j++){ ans=min(ans,a[0][j]); ans=min(ans,a[1][j]); } cout<<ans<<endl; return 0; } /* 6 8 3 3 3 3 1 2 1 2 3 4 3 4 5 5 5 5 4 3 4 3 4 4 4 4 2 1 2 1 3 6 3 6 */
#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...