답안 #137998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137998 2019-07-28T20:15:21 Z vardan__02 Chessboard (IZhO18_chessboard) C++14
70 / 100
500 ms 4088 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
ll n,k,p,u,ans,i,j,v,x1[100005],x2[100005],y[100005],y2[100005],ans1,ans2,t,q;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=k;i++)
    {
        cin>>x1[i]>>y[i]>>x2[i]>>y2[i];
        ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
        t1=x2[i]-x1[i]+1;
        if(x1[i]%2==0)
        {
            zuyg1+=(t1+1)/2;
            kent1+=t1/2;
        }
        else
        {
            kent1+=(t1+1)/2;
            zuyg1+=t1/2;
        }
        t2=y2[i]-y[i]+1;
        if(y[i]%2==0)
        {
            zuyg2+=(t2+1)/2;
            kent2+=t2/2;
        }
        else
        {
            kent2+=(t2+1)/2;
            zuyg2+=t2/2;
        }
        u+=kent1*kent2+zuyg1*zuyg2;
        v+=kent1*zuyg2+zuyg1*kent2;
    }
    if(n%2==0)
        p=n*n/2;
    else
        p=n*n/2+1;
    q=n*n/2;
    ans=min(p-u+v,q-v+u);
    for(j=2;j<=n;j++)
    {
        if(n%j==0)
        {
            ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
            u=0;
            v=0;
            t=n/j;
            for(i=1;i<=k;i++)
            {
                ll g,h;
                if(x1[i]%t==0)
                    g=x1[i]/t;
                else
                    g=x1[i]/t+1;
                if(y[i]%t==0)
                    h=y[i]/t;
                else
                    h=y[i]/t+1;
                if(h%2==g%2)
                    u++;
                else
                    v++;
            }
            q=n/j;
            if(j%2==1)
            ans1=j*j/2+1;
            else
            ans1=j*j/2;
            ans1=ans1*q*q;
            ans1=ans1-u+v;
            ans2=j*j/2;
            ans2=ans2*q*q;
            ans2=ans2-v+u;
            ans=min(ans,ans2);
            ans=min(ans,ans1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:65:16: warning: unused variable 'kent1' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                ^~~~~
chessboard.cpp:65:24: warning: unused variable 'kent2' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                        ^~~~~
chessboard.cpp:65:32: warning: unused variable 'zuyg1' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                                ^~~~~
chessboard.cpp:65:40: warning: unused variable 'zuyg2' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                                        ^~~~~
chessboard.cpp:65:48: warning: unused variable 't1' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                                                ^~
chessboard.cpp:65:51: warning: unused variable 't2' [-Wunused-variable]
             ll kent1=0,kent2=0,zuyg1=0,zuyg2=0,t1,t2;
                                                   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3064 KB Output is correct
2 Correct 10 ms 1144 KB Output is correct
3 Correct 22 ms 2296 KB Output is correct
4 Correct 23 ms 2552 KB Output is correct
5 Correct 29 ms 2808 KB Output is correct
6 Correct 19 ms 2168 KB Output is correct
7 Correct 6 ms 760 KB Output is correct
8 Correct 20 ms 2296 KB Output is correct
9 Correct 46 ms 3932 KB Output is correct
10 Correct 27 ms 2628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 15 ms 1656 KB Output is correct
17 Correct 36 ms 3488 KB Output is correct
18 Correct 51 ms 3932 KB Output is correct
19 Correct 123 ms 3672 KB Output is correct
20 Correct 134 ms 3960 KB Output is correct
21 Correct 34 ms 3320 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 28 ms 2164 KB Output is correct
24 Correct 44 ms 3704 KB Output is correct
25 Correct 7 ms 760 KB Output is correct
26 Correct 29 ms 2676 KB Output is correct
27 Correct 39 ms 3036 KB Output is correct
28 Correct 47 ms 3936 KB Output is correct
29 Correct 15 ms 1912 KB Output is correct
30 Correct 3 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3064 KB Output is correct
2 Correct 10 ms 1144 KB Output is correct
3 Correct 22 ms 2296 KB Output is correct
4 Correct 23 ms 2552 KB Output is correct
5 Correct 29 ms 2808 KB Output is correct
6 Correct 19 ms 2168 KB Output is correct
7 Correct 6 ms 760 KB Output is correct
8 Correct 20 ms 2296 KB Output is correct
9 Correct 46 ms 3932 KB Output is correct
10 Correct 27 ms 2628 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 424 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 15 ms 1656 KB Output is correct
27 Correct 36 ms 3488 KB Output is correct
28 Correct 51 ms 3932 KB Output is correct
29 Correct 123 ms 3672 KB Output is correct
30 Correct 134 ms 3960 KB Output is correct
31 Correct 34 ms 3320 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 28 ms 2164 KB Output is correct
34 Correct 44 ms 3704 KB Output is correct
35 Correct 7 ms 760 KB Output is correct
36 Correct 29 ms 2676 KB Output is correct
37 Correct 39 ms 3036 KB Output is correct
38 Correct 47 ms 3936 KB Output is correct
39 Correct 15 ms 1912 KB Output is correct
40 Correct 3 ms 632 KB Output is correct
41 Correct 108 ms 3448 KB Output is correct
42 Correct 54 ms 3832 KB Output is correct
43 Correct 72 ms 3448 KB Output is correct
44 Correct 53 ms 3704 KB Output is correct
45 Correct 51 ms 4088 KB Output is correct
46 Correct 121 ms 3832 KB Output is correct
47 Correct 43 ms 3576 KB Output is correct
48 Correct 63 ms 3628 KB Output is correct
49 Correct 49 ms 3452 KB Output is correct
50 Correct 454 ms 3836 KB Output is correct
51 Correct 485 ms 3960 KB Output is correct
52 Correct 453 ms 3832 KB Output is correct
53 Correct 482 ms 3960 KB Output is correct
54 Correct 445 ms 3704 KB Output is correct
55 Correct 500 ms 3960 KB Output is correct
56 Correct 434 ms 3600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 33 ms 3064 KB Output is correct
10 Correct 10 ms 1144 KB Output is correct
11 Correct 22 ms 2296 KB Output is correct
12 Correct 23 ms 2552 KB Output is correct
13 Correct 29 ms 2808 KB Output is correct
14 Correct 19 ms 2168 KB Output is correct
15 Correct 6 ms 760 KB Output is correct
16 Correct 20 ms 2296 KB Output is correct
17 Correct 46 ms 3932 KB Output is correct
18 Correct 27 ms 2628 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 424 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 15 ms 1656 KB Output is correct
35 Correct 36 ms 3488 KB Output is correct
36 Correct 51 ms 3932 KB Output is correct
37 Correct 123 ms 3672 KB Output is correct
38 Correct 134 ms 3960 KB Output is correct
39 Correct 34 ms 3320 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 28 ms 2164 KB Output is correct
42 Correct 44 ms 3704 KB Output is correct
43 Correct 7 ms 760 KB Output is correct
44 Correct 29 ms 2676 KB Output is correct
45 Correct 39 ms 3036 KB Output is correct
46 Correct 47 ms 3936 KB Output is correct
47 Correct 15 ms 1912 KB Output is correct
48 Correct 3 ms 632 KB Output is correct
49 Correct 108 ms 3448 KB Output is correct
50 Correct 54 ms 3832 KB Output is correct
51 Correct 72 ms 3448 KB Output is correct
52 Correct 53 ms 3704 KB Output is correct
53 Correct 51 ms 4088 KB Output is correct
54 Correct 121 ms 3832 KB Output is correct
55 Correct 43 ms 3576 KB Output is correct
56 Correct 63 ms 3628 KB Output is correct
57 Correct 49 ms 3452 KB Output is correct
58 Correct 454 ms 3836 KB Output is correct
59 Correct 485 ms 3960 KB Output is correct
60 Correct 453 ms 3832 KB Output is correct
61 Correct 482 ms 3960 KB Output is correct
62 Correct 445 ms 3704 KB Output is correct
63 Correct 500 ms 3960 KB Output is correct
64 Correct 434 ms 3600 KB Output is correct
65 Correct 2 ms 376 KB Output is correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Halted 0 ms 0 KB -