# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168428 | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 47 ms | 2040 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long int
#define fr first
#define sc second
using namespace std;
int n,k,i,j,x,y,res;
pair<int,int>p[100001];
bool a[1001][1001];
int get(int f){
int cnt=0,c[2]={0};
for(int i=0;i<k;i++){
c[(p[i].fr/f+p[i].sc/f)%2]++;
}
int m=n/f;
res=(m/2)*m+((m%2)*(m/2))-c[1]+c[0];
res=min(res,(m/2)*m+((m%2)*((m+1)/2))-c[0]+c[1]);
return res;
}
/*void subtask2(){
int c[2];
c[0]=c[1]=0;
for(i=0;i<k;i++){
scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc);
p[i].fr--;
p[i].sc--;
c[(p[i].fr+p[i].sc)%2]++;
}
res=(n/2)*n+((n%2)*(n/2))-c[1]+c[0];
res=min(res,(n/2)*n+((n%2)*((n+1)/2))-c[0]+c[1]);
printf("%lld",res);
exit(0);
}*/
main(){
scanf("%lld%lld",&n,&k);
//if(n>1000)subtask2();
for(i=0;i<k;i++){
scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc);
p[i].fr--;
p[i].sc--;
//a[p[i].fr][p[i].sc]=1;
}
res=get(1);
for(j=2;j*j<=n;j++){
if(n%j==0){
res=min(res,get(j));
res=min(res,get(n/j));
}
}
printf("%lld",res);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |