# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168425 | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 661 ms | 4476 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 q){
int cnt=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
x=i/f;
y=j/f;
if(q){
if((x+y)%2==0){
if(a[i][j])cnt++;
}else{
if(!a[i][j])cnt++;
}
}else{
if((x+y)%2==0){
if(!a[i][j])cnt++;
}else{
if(a[i][j])cnt++;
}
}
}
return cnt;
}
int get(int f){
return min(get(f,0),get(f,1));
}
main(){
scanf("%lld%lld",&n,&k);
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... |