이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
llo n,k;
llo aa,bb,cc,dd;
vector<pair<llo,llo>> cur;
llo check(llo nn){
if(nn==n){
return n*n;
}
llo co;
if((n/nn)%2==0){
co=(n*n)/2;
}
else{
co=(n*n-nn*nn)/2;
}
//cout<<co<<":";
for(auto i:cur){
if((i.a/nn+i.b/nn)%2==1){
co-=1;
}
else{
co+=1;
}
}
llo co2;
if((n/nn)%2==0){
co2=(n*n)/2;
}
else{
co2=(n*n+nn*nn)/2;
}
// cout<<co2<<endl;
for(auto i:cur){
if((i.a/nn+i.b/nn)%2==0){
co2-=1;
}
else{
co2+=1;
}
}
// cout<<nn<<","<<co<<","<<co2<<endl;
return min(co,co2);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>k;
for(llo i=0;i<k;i++){
cin>>aa>>bb>>cc>>dd;
aa-=1;
bb-=1;
cur.pb({aa,bb});
}
llo ans=n*n;
for(llo i=1;i*i<=n;i++){
if(n%i==0){
ans=min(ans,check(i));
ans=min(ans,check(n/i));
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |