Submission #338441

# Submission time Handle Problem Language Result Execution time Memory
338441 2020-12-23T06:20:31 Z Kerim Chessboard (IZhO18_chessboard) C++17
70 / 100
370 ms 1260 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
ll res=1e10;
int n,k;
PII arr[MAXN];
ll cnt[2];
void solve(int x,int t){
	if((n/x)&1){
		cnt[0]=cnt[1]=(n*1LL*n-x*1LL*x)/2;
		cnt[t]+=x*1LL*x;
	}
	else
		cnt[0]=cnt[1]=(n*1LL*n)/2;
	ll ans=cnt[1];
	//cout<<x<<" "<<t<<" "<<cnt[0]<<" "<<cnt[1]<<endl;
	for(int i=0;i<k;i++){
		int a=arr[i].ff/x,b=arr[i].ss/x;
		int col=((a%2)^(b%2)^t);
		if(!col)
			ans++;
		else
			ans--;	
	}
	umin(res,ans);
}
int main(){
   // freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&k);
    for(int i=0;i<k;i++){
    	int x,y,xx,yy;
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		x--;y--;xx--;yy--;
		assert(x==xx and y==yy);	
		arr[i]=mp(x,y);
    }
    for(int i=1;i<n;i++)
    	if(n%i==0)
    		solve(i,0),solve(i,1);
    printf("%lld\n",res);
	return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
chessboard.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |   scanf("%d%d%d%d",&x,&y,&xx,&yy);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 748 KB Output is correct
2 Correct 7 ms 492 KB Output is correct
3 Correct 19 ms 748 KB Output is correct
4 Correct 18 ms 620 KB Output is correct
5 Correct 24 ms 748 KB Output is correct
6 Correct 15 ms 620 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 15 ms 620 KB Output is correct
9 Correct 37 ms 1004 KB Output is correct
10 Correct 21 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 492 KB Output is correct
17 Correct 32 ms 1004 KB Output is correct
18 Correct 41 ms 1132 KB Output is correct
19 Correct 85 ms 1004 KB Output is correct
20 Correct 95 ms 1132 KB Output is correct
21 Correct 28 ms 1004 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 22 ms 620 KB Output is correct
24 Correct 37 ms 1004 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 23 ms 748 KB Output is correct
27 Correct 31 ms 876 KB Output is correct
28 Correct 38 ms 1004 KB Output is correct
29 Correct 12 ms 620 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 748 KB Output is correct
2 Correct 7 ms 492 KB Output is correct
3 Correct 19 ms 748 KB Output is correct
4 Correct 18 ms 620 KB Output is correct
5 Correct 24 ms 748 KB Output is correct
6 Correct 15 ms 620 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 15 ms 620 KB Output is correct
9 Correct 37 ms 1004 KB Output is correct
10 Correct 21 ms 748 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 11 ms 492 KB Output is correct
27 Correct 32 ms 1004 KB Output is correct
28 Correct 41 ms 1132 KB Output is correct
29 Correct 85 ms 1004 KB Output is correct
30 Correct 95 ms 1132 KB Output is correct
31 Correct 28 ms 1004 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 22 ms 620 KB Output is correct
34 Correct 37 ms 1004 KB Output is correct
35 Correct 5 ms 364 KB Output is correct
36 Correct 23 ms 748 KB Output is correct
37 Correct 31 ms 876 KB Output is correct
38 Correct 38 ms 1004 KB Output is correct
39 Correct 12 ms 620 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 82 ms 1004 KB Output is correct
42 Correct 44 ms 1132 KB Output is correct
43 Correct 57 ms 1004 KB Output is correct
44 Correct 44 ms 1004 KB Output is correct
45 Correct 40 ms 1152 KB Output is correct
46 Correct 91 ms 1004 KB Output is correct
47 Correct 37 ms 1132 KB Output is correct
48 Correct 51 ms 1132 KB Output is correct
49 Correct 39 ms 1132 KB Output is correct
50 Correct 334 ms 1132 KB Output is correct
51 Correct 357 ms 1132 KB Output is correct
52 Correct 332 ms 1084 KB Output is correct
53 Correct 354 ms 1132 KB Output is correct
54 Correct 327 ms 1260 KB Output is correct
55 Correct 370 ms 1260 KB Output is correct
56 Correct 317 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 30 ms 748 KB Output is correct
10 Correct 7 ms 492 KB Output is correct
11 Correct 19 ms 748 KB Output is correct
12 Correct 18 ms 620 KB Output is correct
13 Correct 24 ms 748 KB Output is correct
14 Correct 15 ms 620 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 15 ms 620 KB Output is correct
17 Correct 37 ms 1004 KB Output is correct
18 Correct 21 ms 748 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 0 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 11 ms 492 KB Output is correct
35 Correct 32 ms 1004 KB Output is correct
36 Correct 41 ms 1132 KB Output is correct
37 Correct 85 ms 1004 KB Output is correct
38 Correct 95 ms 1132 KB Output is correct
39 Correct 28 ms 1004 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 22 ms 620 KB Output is correct
42 Correct 37 ms 1004 KB Output is correct
43 Correct 5 ms 364 KB Output is correct
44 Correct 23 ms 748 KB Output is correct
45 Correct 31 ms 876 KB Output is correct
46 Correct 38 ms 1004 KB Output is correct
47 Correct 12 ms 620 KB Output is correct
48 Correct 1 ms 364 KB Output is correct
49 Correct 82 ms 1004 KB Output is correct
50 Correct 44 ms 1132 KB Output is correct
51 Correct 57 ms 1004 KB Output is correct
52 Correct 44 ms 1004 KB Output is correct
53 Correct 40 ms 1152 KB Output is correct
54 Correct 91 ms 1004 KB Output is correct
55 Correct 37 ms 1132 KB Output is correct
56 Correct 51 ms 1132 KB Output is correct
57 Correct 39 ms 1132 KB Output is correct
58 Correct 334 ms 1132 KB Output is correct
59 Correct 357 ms 1132 KB Output is correct
60 Correct 332 ms 1084 KB Output is correct
61 Correct 354 ms 1132 KB Output is correct
62 Correct 327 ms 1260 KB Output is correct
63 Correct 370 ms 1260 KB Output is correct
64 Correct 317 ms 1004 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
67 Halted 0 ms 0 KB -