# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168428 | 2019-12-13T04:45:12 Z | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 47 ms | 2040 KB |
#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); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1528 KB | Output is correct |
2 | Correct | 10 ms | 888 KB | Output is correct |
3 | Correct | 22 ms | 1272 KB | Output is correct |
4 | Correct | 23 ms | 1272 KB | Output is correct |
5 | Correct | 29 ms | 1400 KB | Output is correct |
6 | Correct | 19 ms | 1272 KB | Output is correct |
7 | Correct | 6 ms | 632 KB | Output is correct |
8 | Correct | 19 ms | 1144 KB | Output is correct |
9 | Correct | 47 ms | 2040 KB | Output is correct |
10 | Correct | 27 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1528 KB | Output is correct |
2 | Correct | 10 ms | 888 KB | Output is correct |
3 | Correct | 22 ms | 1272 KB | Output is correct |
4 | Correct | 23 ms | 1272 KB | Output is correct |
5 | Correct | 29 ms | 1400 KB | Output is correct |
6 | Correct | 19 ms | 1272 KB | Output is correct |
7 | Correct | 6 ms | 632 KB | Output is correct |
8 | Correct | 19 ms | 1144 KB | Output is correct |
9 | Correct | 47 ms | 2040 KB | Output is correct |
10 | Correct | 27 ms | 1400 KB | Output is correct |
11 | Incorrect | 2 ms | 376 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |