제출 #168425

#제출 시각아이디문제언어결과실행 시간메모리
168425juggernautChessboard (IZhO18_chessboard)C++14
39 / 100
661 ms4476 KiB
#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) 메시지

chessboard.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~
chessboard.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...