답안 #44118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44118 2018-03-30T03:34:00 Z Nordway Chessboard (IZhO18_chessboard) C++14
70 / 100
372 ms 36776 KB
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define low_b lower_bound
#define up_b upper_bound
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;

const int N = 1e+5 + 5;

pair < pair < int, int >, pair < int, int > > a[N];
ll ans = LLONG_MAX;
ll n, k;
void solve(int v){
    ll d = n / v;
    ll l = ((d / 2) * (d / 2) + ((d + 1) / 2) * ((d + 1) / 2)) * v * v;
    ll r = ((d / 2) * ((d + 1) / 2) + ((d + 1) / 2) * (d / 2)) * v * v;
    for(int i = 1; i <= k; i++){
        int x = a[i].x.x;
        int y = a[i].x.y;
        ll val1 = (x + v - 1) / v;
        ll val2 = (y + v - 1) / v;
        if((val1 + val2) % 2 == 0){
            l--;
            r++;
        }
        else{
            l++;
            r--;
        }
    }
    ans = min(ans, min(l, r));
}

int main(){
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        cin >> a[i].x.x >> a[i].x.y >> a[i].y.x >> a[i].y.y;
    }
    solve(1);
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            solve(i);
            solve(n / i);
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 1372 KB Output is correct
2 Correct 25 ms 1372 KB Output is correct
3 Correct 107 ms 1372 KB Output is correct
4 Correct 61 ms 1372 KB Output is correct
5 Correct 83 ms 1468 KB Output is correct
6 Correct 55 ms 1468 KB Output is correct
7 Correct 13 ms 1468 KB Output is correct
8 Correct 53 ms 1468 KB Output is correct
9 Correct 171 ms 1968 KB Output is correct
10 Correct 73 ms 1968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1968 KB Output is correct
2 Correct 2 ms 1968 KB Output is correct
3 Correct 2 ms 1968 KB Output is correct
4 Correct 3 ms 1968 KB Output is correct
5 Correct 3 ms 1968 KB Output is correct
6 Correct 2 ms 1968 KB Output is correct
7 Correct 3 ms 1968 KB Output is correct
8 Correct 3 ms 1968 KB Output is correct
9 Correct 2 ms 1968 KB Output is correct
10 Correct 2 ms 1968 KB Output is correct
11 Correct 2 ms 1968 KB Output is correct
12 Correct 3 ms 1968 KB Output is correct
13 Correct 3 ms 1968 KB Output is correct
14 Correct 4 ms 1968 KB Output is correct
15 Correct 3 ms 1968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1968 KB Output is correct
2 Correct 2 ms 1968 KB Output is correct
3 Correct 2 ms 1968 KB Output is correct
4 Correct 3 ms 1968 KB Output is correct
5 Correct 3 ms 1968 KB Output is correct
6 Correct 2 ms 1968 KB Output is correct
7 Correct 3 ms 1968 KB Output is correct
8 Correct 3 ms 1968 KB Output is correct
9 Correct 2 ms 1968 KB Output is correct
10 Correct 2 ms 1968 KB Output is correct
11 Correct 2 ms 1968 KB Output is correct
12 Correct 3 ms 1968 KB Output is correct
13 Correct 3 ms 1968 KB Output is correct
14 Correct 4 ms 1968 KB Output is correct
15 Correct 3 ms 1968 KB Output is correct
16 Correct 31 ms 1968 KB Output is correct
17 Correct 93 ms 1968 KB Output is correct
18 Correct 107 ms 2096 KB Output is correct
19 Correct 135 ms 2096 KB Output is correct
20 Correct 150 ms 2172 KB Output is correct
21 Correct 85 ms 2172 KB Output is correct
22 Correct 3 ms 2172 KB Output is correct
23 Correct 50 ms 2172 KB Output is correct
24 Correct 95 ms 2172 KB Output is correct
25 Correct 12 ms 2172 KB Output is correct
26 Correct 61 ms 2172 KB Output is correct
27 Correct 76 ms 2172 KB Output is correct
28 Correct 108 ms 2172 KB Output is correct
29 Correct 36 ms 2172 KB Output is correct
30 Correct 5 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 1372 KB Output is correct
2 Correct 25 ms 1372 KB Output is correct
3 Correct 107 ms 1372 KB Output is correct
4 Correct 61 ms 1372 KB Output is correct
5 Correct 83 ms 1468 KB Output is correct
6 Correct 55 ms 1468 KB Output is correct
7 Correct 13 ms 1468 KB Output is correct
8 Correct 53 ms 1468 KB Output is correct
9 Correct 171 ms 1968 KB Output is correct
10 Correct 73 ms 1968 KB Output is correct
11 Correct 2 ms 1968 KB Output is correct
12 Correct 2 ms 1968 KB Output is correct
13 Correct 2 ms 1968 KB Output is correct
14 Correct 3 ms 1968 KB Output is correct
15 Correct 3 ms 1968 KB Output is correct
16 Correct 2 ms 1968 KB Output is correct
17 Correct 3 ms 1968 KB Output is correct
18 Correct 3 ms 1968 KB Output is correct
19 Correct 2 ms 1968 KB Output is correct
20 Correct 2 ms 1968 KB Output is correct
21 Correct 2 ms 1968 KB Output is correct
22 Correct 3 ms 1968 KB Output is correct
23 Correct 3 ms 1968 KB Output is correct
24 Correct 4 ms 1968 KB Output is correct
25 Correct 3 ms 1968 KB Output is correct
26 Correct 31 ms 1968 KB Output is correct
27 Correct 93 ms 1968 KB Output is correct
28 Correct 107 ms 2096 KB Output is correct
29 Correct 135 ms 2096 KB Output is correct
30 Correct 150 ms 2172 KB Output is correct
31 Correct 85 ms 2172 KB Output is correct
32 Correct 3 ms 2172 KB Output is correct
33 Correct 50 ms 2172 KB Output is correct
34 Correct 95 ms 2172 KB Output is correct
35 Correct 12 ms 2172 KB Output is correct
36 Correct 61 ms 2172 KB Output is correct
37 Correct 76 ms 2172 KB Output is correct
38 Correct 108 ms 2172 KB Output is correct
39 Correct 36 ms 2172 KB Output is correct
40 Correct 5 ms 2172 KB Output is correct
41 Correct 166 ms 3864 KB Output is correct
42 Correct 148 ms 6452 KB Output is correct
43 Correct 137 ms 8188 KB Output is correct
44 Correct 194 ms 10516 KB Output is correct
45 Correct 146 ms 13168 KB Output is correct
46 Correct 172 ms 15148 KB Output is correct
47 Correct 124 ms 17116 KB Output is correct
48 Correct 141 ms 19168 KB Output is correct
49 Correct 130 ms 21128 KB Output is correct
50 Correct 344 ms 23396 KB Output is correct
51 Correct 366 ms 25912 KB Output is correct
52 Correct 334 ms 28024 KB Output is correct
53 Correct 363 ms 30444 KB Output is correct
54 Correct 341 ms 32484 KB Output is correct
55 Correct 372 ms 35008 KB Output is correct
56 Correct 321 ms 36776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 89 ms 1372 KB Output is correct
10 Correct 25 ms 1372 KB Output is correct
11 Correct 107 ms 1372 KB Output is correct
12 Correct 61 ms 1372 KB Output is correct
13 Correct 83 ms 1468 KB Output is correct
14 Correct 55 ms 1468 KB Output is correct
15 Correct 13 ms 1468 KB Output is correct
16 Correct 53 ms 1468 KB Output is correct
17 Correct 171 ms 1968 KB Output is correct
18 Correct 73 ms 1968 KB Output is correct
19 Correct 2 ms 1968 KB Output is correct
20 Correct 2 ms 1968 KB Output is correct
21 Correct 2 ms 1968 KB Output is correct
22 Correct 3 ms 1968 KB Output is correct
23 Correct 3 ms 1968 KB Output is correct
24 Correct 2 ms 1968 KB Output is correct
25 Correct 3 ms 1968 KB Output is correct
26 Correct 3 ms 1968 KB Output is correct
27 Correct 2 ms 1968 KB Output is correct
28 Correct 2 ms 1968 KB Output is correct
29 Correct 2 ms 1968 KB Output is correct
30 Correct 3 ms 1968 KB Output is correct
31 Correct 3 ms 1968 KB Output is correct
32 Correct 4 ms 1968 KB Output is correct
33 Correct 3 ms 1968 KB Output is correct
34 Correct 31 ms 1968 KB Output is correct
35 Correct 93 ms 1968 KB Output is correct
36 Correct 107 ms 2096 KB Output is correct
37 Correct 135 ms 2096 KB Output is correct
38 Correct 150 ms 2172 KB Output is correct
39 Correct 85 ms 2172 KB Output is correct
40 Correct 3 ms 2172 KB Output is correct
41 Correct 50 ms 2172 KB Output is correct
42 Correct 95 ms 2172 KB Output is correct
43 Correct 12 ms 2172 KB Output is correct
44 Correct 61 ms 2172 KB Output is correct
45 Correct 76 ms 2172 KB Output is correct
46 Correct 108 ms 2172 KB Output is correct
47 Correct 36 ms 2172 KB Output is correct
48 Correct 5 ms 2172 KB Output is correct
49 Correct 166 ms 3864 KB Output is correct
50 Correct 148 ms 6452 KB Output is correct
51 Correct 137 ms 8188 KB Output is correct
52 Correct 194 ms 10516 KB Output is correct
53 Correct 146 ms 13168 KB Output is correct
54 Correct 172 ms 15148 KB Output is correct
55 Correct 124 ms 17116 KB Output is correct
56 Correct 141 ms 19168 KB Output is correct
57 Correct 130 ms 21128 KB Output is correct
58 Correct 344 ms 23396 KB Output is correct
59 Correct 366 ms 25912 KB Output is correct
60 Correct 334 ms 28024 KB Output is correct
61 Correct 363 ms 30444 KB Output is correct
62 Correct 341 ms 32484 KB Output is correct
63 Correct 372 ms 35008 KB Output is correct
64 Correct 321 ms 36776 KB Output is correct
65 Correct 2 ms 36776 KB Output is correct
66 Incorrect 2 ms 36776 KB Output isn't correct
67 Halted 0 ms 0 KB -