답안 #378648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378648 2021-03-17T02:45:15 Z eric_xiao Chessboard (IZhO18_chessboard) C++14
70 / 100
282 ms 512 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> can;
ll B[100009],C[100009];
ll cal(ll x,ll y,ll len)
{
    ll a = x/len,b = y/len;
    return (a+b+1)%2;
}
int main()
{
    ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
    cin >> N >> k;
    for(i = 1;i < N;i++)
    {
        if(N % i == 0) can.push_back(i);
    }
    for(i = 0;i < k;i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        x1--;
        y1--;
        x2--;
        y2--;
        for(j = 0;j < can.size();j++)
        {
            B[j] += cal(x1,y1,can[j]);
        }
    }
    ll ans = 10000000000000;
    for(i = 0;i < can.size();i++)
    {
        C[i] = k-B[i];
        ll tp = can[i];
        ll cnt = ((N/tp)*(N/tp)+1)/2;
        cnt *= tp*tp;
        ans = min({ans,cnt-B[i]+C[i],(N*N-cnt)-C[i]+B[i]});
    }
    cout << ans << endl;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:26:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(j = 0;j < can.size();j++)
      |                   ~~^~~~~~~~~~~~
chessboard.cpp:32:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(i = 0;i < can.size();i++)
      |               ~~^~~~~~~~~~~~
chessboard.cpp:13:10: warning: unused variable 'M' [-Wunused-variable]
   13 |     ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
      |          ^
chessboard.cpp:13:30: warning: unused variable 'a' [-Wunused-variable]
   13 |     ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
      |                              ^
chessboard.cpp:13:32: warning: unused variable 'b' [-Wunused-variable]
   13 |     ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
      |                                ^
chessboard.cpp:13:34: warning: unused variable 'c' [-Wunused-variable]
   13 |     ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
      |                                  ^
chessboard.cpp:13:36: warning: unused variable 'd' [-Wunused-variable]
   13 |     ll N,M,i,j,k,x1,x2,y1,y2,a,b,c,d;
      |                                    ^
# 결과 실행 시간 메모리 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 512 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 79 ms 364 KB Output is correct
2 Correct 22 ms 364 KB Output is correct
3 Correct 46 ms 364 KB Output is correct
4 Correct 46 ms 364 KB Output is correct
5 Correct 63 ms 364 KB Output is correct
6 Correct 40 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 42 ms 364 KB Output is correct
9 Correct 109 ms 492 KB Output is correct
10 Correct 59 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 2 ms 508 KB Output is correct
15 Correct 2 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 2 ms 508 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 27 ms 364 KB Output is correct
17 Correct 76 ms 364 KB Output is correct
18 Correct 91 ms 364 KB Output is correct
19 Correct 106 ms 364 KB Output is correct
20 Correct 134 ms 364 KB Output is correct
21 Correct 72 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 43 ms 364 KB Output is correct
24 Correct 95 ms 364 KB Output is correct
25 Correct 9 ms 364 KB Output is correct
26 Correct 52 ms 364 KB Output is correct
27 Correct 67 ms 364 KB Output is correct
28 Correct 100 ms 492 KB Output is correct
29 Correct 30 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 364 KB Output is correct
2 Correct 22 ms 364 KB Output is correct
3 Correct 46 ms 364 KB Output is correct
4 Correct 46 ms 364 KB Output is correct
5 Correct 63 ms 364 KB Output is correct
6 Correct 40 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 42 ms 364 KB Output is correct
9 Correct 109 ms 492 KB Output is correct
10 Correct 59 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 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 2 ms 508 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 27 ms 364 KB Output is correct
27 Correct 76 ms 364 KB Output is correct
28 Correct 91 ms 364 KB Output is correct
29 Correct 106 ms 364 KB Output is correct
30 Correct 134 ms 364 KB Output is correct
31 Correct 72 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 43 ms 364 KB Output is correct
34 Correct 95 ms 364 KB Output is correct
35 Correct 9 ms 364 KB Output is correct
36 Correct 52 ms 364 KB Output is correct
37 Correct 67 ms 364 KB Output is correct
38 Correct 100 ms 492 KB Output is correct
39 Correct 30 ms 364 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 120 ms 380 KB Output is correct
42 Correct 117 ms 492 KB Output is correct
43 Correct 107 ms 364 KB Output is correct
44 Correct 112 ms 492 KB Output is correct
45 Correct 117 ms 364 KB Output is correct
46 Correct 137 ms 364 KB Output is correct
47 Correct 99 ms 492 KB Output is correct
48 Correct 107 ms 364 KB Output is correct
49 Correct 113 ms 364 KB Output is correct
50 Correct 261 ms 380 KB Output is correct
51 Correct 274 ms 492 KB Output is correct
52 Correct 257 ms 512 KB Output is correct
53 Correct 278 ms 492 KB Output is correct
54 Correct 254 ms 492 KB Output is correct
55 Correct 282 ms 492 KB Output is correct
56 Correct 243 ms 492 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 512 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 79 ms 364 KB Output is correct
10 Correct 22 ms 364 KB Output is correct
11 Correct 46 ms 364 KB Output is correct
12 Correct 46 ms 364 KB Output is correct
13 Correct 63 ms 364 KB Output is correct
14 Correct 40 ms 364 KB Output is correct
15 Correct 9 ms 364 KB Output is correct
16 Correct 42 ms 364 KB Output is correct
17 Correct 109 ms 492 KB Output is correct
18 Correct 59 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 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 2 ms 508 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 27 ms 364 KB Output is correct
35 Correct 76 ms 364 KB Output is correct
36 Correct 91 ms 364 KB Output is correct
37 Correct 106 ms 364 KB Output is correct
38 Correct 134 ms 364 KB Output is correct
39 Correct 72 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 43 ms 364 KB Output is correct
42 Correct 95 ms 364 KB Output is correct
43 Correct 9 ms 364 KB Output is correct
44 Correct 52 ms 364 KB Output is correct
45 Correct 67 ms 364 KB Output is correct
46 Correct 100 ms 492 KB Output is correct
47 Correct 30 ms 364 KB Output is correct
48 Correct 3 ms 364 KB Output is correct
49 Correct 120 ms 380 KB Output is correct
50 Correct 117 ms 492 KB Output is correct
51 Correct 107 ms 364 KB Output is correct
52 Correct 112 ms 492 KB Output is correct
53 Correct 117 ms 364 KB Output is correct
54 Correct 137 ms 364 KB Output is correct
55 Correct 99 ms 492 KB Output is correct
56 Correct 107 ms 364 KB Output is correct
57 Correct 113 ms 364 KB Output is correct
58 Correct 261 ms 380 KB Output is correct
59 Correct 274 ms 492 KB Output is correct
60 Correct 257 ms 512 KB Output is correct
61 Correct 278 ms 492 KB Output is correct
62 Correct 254 ms 492 KB Output is correct
63 Correct 282 ms 492 KB Output is correct
64 Correct 243 ms 492 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Incorrect 1 ms 364 KB Output isn't correct
67 Halted 0 ms 0 KB -