# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
340383 | 2020-12-27T13:38:19 Z | scales | Chessboard (IZhO18_chessboard) | C++17 | 497 ms | 3564 KB |
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,g,p,l,r,sum,maxi,kol,v,f,s,h,z1,rov; dno=0; cin>>n; cin>>k; z=0; tip=0; maxi=100000000000; vector<long long> a(k),b(k),c(k),d(k); for(i=0;i<k;i++) { cin>>a[i]; cin>>b[i]; cin>>c[i]; cin>>d[i]; a[i]--; b[i]--; c[i]--; d[i]--; tip=tip+(c[i]-a[i]+1)*(d[i]-b[i]+1); } vector<long long> viv; for(i=1;i<n;i++) { if(n%i==0) { viv.push_back(i); } } z1=viv.size(); //cout<<"tip="<<tip<<endl; //cout<<"z1="<<z1<<endl; for(i=0;i<z1;i++) { kol=0; w=viv[i]; //cout<<"w="<<w<<endl; //cout<<"w="<<w<<endl; for(j=0;j<k;j++) { //cout<<"a="<<a[j]<<" b="<<b[j]<<" "<<a[j]%(2*w)<<" "<<b[j]%(2*w)<<endl; z=(c[j]-a[j])/(2*w); g=z*w; x=a[j]%(2*w); y=c[j]%(2*w); if(x<=y) { l=x; r=min(w-1,y); } else { swap(x,y); l=x; r=min(w-1,y); rov=0; rov=max(rov,r-l+1); rov=w-rov; r=rov; l=1; } g=g+max(dno,(r-l+1)); z=(d[j]-b[j])/(2*w); x=b[j]%(2*w); y=d[j]%(2*w); h=z*w; // cout<<"h="<<h<<" z="<<z<<endl; if(x<=y) { l=x; r=min(w-1,y); } else { swap(x,y); l=x; r=min(w-1,y); rov=0; rov=max(rov,r-l+1); rov=w-rov; r=rov; l=1; } //cout<<"h="<<h<<" dno="<<dno<<endl; h=h+max(dno,(r-l+1)); //cout<<"g="<<g<<" h="<<h<<endl; kol=kol+g*(d[j]-b[j]+1-h)+h*(c[j]-a[j]+1-g); } v=(n*n)/(w*w); if(v%2==0) { f=n*n/2; s=n*n/2; } else { s=(n*n-w*w)/2; f=n*n-s; } kol=tip-kol; //cout<<"kol="<<kol<<" f="<<f<<" s="<<s<<" maxi="; maxi=min({maxi,(f-kol+tip-kol),(kol+s-tip+kol)}); //cout<<maxi<<endl; } cout<<maxi<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 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 | 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 | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 2412 KB | Output is correct |
2 | Correct | 7 ms | 876 KB | Output is correct |
3 | Correct | 17 ms | 1516 KB | Output is correct |
4 | Correct | 18 ms | 1772 KB | Output is correct |
5 | Correct | 24 ms | 2028 KB | Output is correct |
6 | Correct | 15 ms | 1388 KB | Output is correct |
7 | Correct | 4 ms | 620 KB | Output is correct |
8 | Correct | 15 ms | 1388 KB | Output is correct |
9 | Correct | 38 ms | 3180 KB | Output is correct |
10 | Correct | 21 ms | 1900 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 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 | 364 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 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 | 364 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 | 12 ms | 1132 KB | Output is correct |
17 | Correct | 34 ms | 2924 KB | Output is correct |
18 | Correct | 42 ms | 3436 KB | Output is correct |
19 | Correct | 110 ms | 3180 KB | Output is correct |
20 | Correct | 121 ms | 3436 KB | Output is correct |
21 | Correct | 29 ms | 3052 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 24 ms | 1648 KB | Output is correct |
24 | Correct | 38 ms | 3180 KB | Output is correct |
25 | Correct | 5 ms | 620 KB | Output is correct |
26 | Correct | 24 ms | 2284 KB | Output is correct |
27 | Correct | 34 ms | 2412 KB | Output is correct |
28 | Correct | 41 ms | 3308 KB | Output is correct |
29 | Correct | 13 ms | 1388 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 2412 KB | Output is correct |
2 | Correct | 7 ms | 876 KB | Output is correct |
3 | Correct | 17 ms | 1516 KB | Output is correct |
4 | Correct | 18 ms | 1772 KB | Output is correct |
5 | Correct | 24 ms | 2028 KB | Output is correct |
6 | Correct | 15 ms | 1388 KB | Output is correct |
7 | Correct | 4 ms | 620 KB | Output is correct |
8 | Correct | 15 ms | 1388 KB | Output is correct |
9 | Correct | 38 ms | 3180 KB | Output is correct |
10 | Correct | 21 ms | 1900 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 | 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 | 12 ms | 1132 KB | Output is correct |
27 | Correct | 34 ms | 2924 KB | Output is correct |
28 | Correct | 42 ms | 3436 KB | Output is correct |
29 | Correct | 110 ms | 3180 KB | Output is correct |
30 | Correct | 121 ms | 3436 KB | Output is correct |
31 | Correct | 29 ms | 3052 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 24 ms | 1648 KB | Output is correct |
34 | Correct | 38 ms | 3180 KB | Output is correct |
35 | Correct | 5 ms | 620 KB | Output is correct |
36 | Correct | 24 ms | 2284 KB | Output is correct |
37 | Correct | 34 ms | 2412 KB | Output is correct |
38 | Correct | 41 ms | 3308 KB | Output is correct |
39 | Correct | 13 ms | 1388 KB | Output is correct |
40 | Correct | 2 ms | 364 KB | Output is correct |
41 | Correct | 100 ms | 2988 KB | Output is correct |
42 | Correct | 46 ms | 3328 KB | Output is correct |
43 | Correct | 66 ms | 2924 KB | Output is correct |
44 | Correct | 45 ms | 3180 KB | Output is correct |
45 | Correct | 44 ms | 3564 KB | Output is correct |
46 | Correct | 113 ms | 3180 KB | Output is correct |
47 | Correct | 38 ms | 3180 KB | Output is correct |
48 | Correct | 56 ms | 3052 KB | Output is correct |
49 | Correct | 42 ms | 2924 KB | Output is correct |
50 | Correct | 446 ms | 3308 KB | Output is correct |
51 | Correct | 474 ms | 3308 KB | Output is correct |
52 | Correct | 442 ms | 3308 KB | Output is correct |
53 | Correct | 475 ms | 3436 KB | Output is correct |
54 | Correct | 439 ms | 3180 KB | Output is correct |
55 | Correct | 497 ms | 3520 KB | Output is correct |
56 | Correct | 423 ms | 3180 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 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 | 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 | 1 ms | 364 KB | Output is correct |
9 | Correct | 27 ms | 2412 KB | Output is correct |
10 | Correct | 7 ms | 876 KB | Output is correct |
11 | Correct | 17 ms | 1516 KB | Output is correct |
12 | Correct | 18 ms | 1772 KB | Output is correct |
13 | Correct | 24 ms | 2028 KB | Output is correct |
14 | Correct | 15 ms | 1388 KB | Output is correct |
15 | Correct | 4 ms | 620 KB | Output is correct |
16 | Correct | 15 ms | 1388 KB | Output is correct |
17 | Correct | 38 ms | 3180 KB | Output is correct |
18 | Correct | 21 ms | 1900 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 | 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 | 12 ms | 1132 KB | Output is correct |
35 | Correct | 34 ms | 2924 KB | Output is correct |
36 | Correct | 42 ms | 3436 KB | Output is correct |
37 | Correct | 110 ms | 3180 KB | Output is correct |
38 | Correct | 121 ms | 3436 KB | Output is correct |
39 | Correct | 29 ms | 3052 KB | Output is correct |
40 | Correct | 1 ms | 364 KB | Output is correct |
41 | Correct | 24 ms | 1648 KB | Output is correct |
42 | Correct | 38 ms | 3180 KB | Output is correct |
43 | Correct | 5 ms | 620 KB | Output is correct |
44 | Correct | 24 ms | 2284 KB | Output is correct |
45 | Correct | 34 ms | 2412 KB | Output is correct |
46 | Correct | 41 ms | 3308 KB | Output is correct |
47 | Correct | 13 ms | 1388 KB | Output is correct |
48 | Correct | 2 ms | 364 KB | Output is correct |
49 | Correct | 100 ms | 2988 KB | Output is correct |
50 | Correct | 46 ms | 3328 KB | Output is correct |
51 | Correct | 66 ms | 2924 KB | Output is correct |
52 | Correct | 45 ms | 3180 KB | Output is correct |
53 | Correct | 44 ms | 3564 KB | Output is correct |
54 | Correct | 113 ms | 3180 KB | Output is correct |
55 | Correct | 38 ms | 3180 KB | Output is correct |
56 | Correct | 56 ms | 3052 KB | Output is correct |
57 | Correct | 42 ms | 2924 KB | Output is correct |
58 | Correct | 446 ms | 3308 KB | Output is correct |
59 | Correct | 474 ms | 3308 KB | Output is correct |
60 | Correct | 442 ms | 3308 KB | Output is correct |
61 | Correct | 475 ms | 3436 KB | Output is correct |
62 | Correct | 439 ms | 3180 KB | Output is correct |
63 | Correct | 497 ms | 3520 KB | Output is correct |
64 | Correct | 423 ms | 3180 KB | Output is correct |
65 | Correct | 0 ms | 364 KB | Output is correct |
66 | Correct | 0 ms | 364 KB | Output is correct |
67 | Incorrect | 471 ms | 3564 KB | Output isn't correct |
68 | Halted | 0 ms | 0 KB | - |