답안 #44117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44117 2018-03-30T03:30:40 Z Nordway Chessboard (IZhO18_chessboard) C++14
39 / 100
161 ms 15872 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];
int ans = INT_MAX;
int n, k;
void solve(int v){
    int d = n / v;
    int l = ((d / 2) * (d / 2) + ((d + 1) / 2) * ((d + 1) / 2)) * v * v;
    int 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;
        int val1 = (x + v - 1) / v;
        int 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 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 2 ms 524 KB Output is correct
8 Correct 2 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 1436 KB Output is correct
2 Correct 27 ms 1436 KB Output is correct
3 Incorrect 59 ms 1436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1436 KB Output is correct
2 Correct 2 ms 1436 KB Output is correct
3 Correct 2 ms 1436 KB Output is correct
4 Correct 3 ms 1436 KB Output is correct
5 Correct 3 ms 1436 KB Output is correct
6 Correct 2 ms 1436 KB Output is correct
7 Correct 3 ms 1436 KB Output is correct
8 Correct 2 ms 1436 KB Output is correct
9 Correct 2 ms 1436 KB Output is correct
10 Correct 2 ms 1436 KB Output is correct
11 Correct 2 ms 1436 KB Output is correct
12 Correct 3 ms 1436 KB Output is correct
13 Correct 3 ms 1436 KB Output is correct
14 Correct 3 ms 1436 KB Output is correct
15 Correct 3 ms 1436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1436 KB Output is correct
2 Correct 2 ms 1436 KB Output is correct
3 Correct 2 ms 1436 KB Output is correct
4 Correct 3 ms 1436 KB Output is correct
5 Correct 3 ms 1436 KB Output is correct
6 Correct 2 ms 1436 KB Output is correct
7 Correct 3 ms 1436 KB Output is correct
8 Correct 2 ms 1436 KB Output is correct
9 Correct 2 ms 1436 KB Output is correct
10 Correct 2 ms 1436 KB Output is correct
11 Correct 2 ms 1436 KB Output is correct
12 Correct 3 ms 1436 KB Output is correct
13 Correct 3 ms 1436 KB Output is correct
14 Correct 3 ms 1436 KB Output is correct
15 Correct 3 ms 1436 KB Output is correct
16 Correct 40 ms 1624 KB Output is correct
17 Correct 99 ms 3860 KB Output is correct
18 Correct 111 ms 5704 KB Output is correct
19 Correct 136 ms 7080 KB Output is correct
20 Correct 161 ms 8764 KB Output is correct
21 Correct 90 ms 9848 KB Output is correct
22 Correct 2 ms 9848 KB Output is correct
23 Correct 71 ms 9944 KB Output is correct
24 Correct 109 ms 12112 KB Output is correct
25 Correct 18 ms 12112 KB Output is correct
26 Correct 99 ms 12832 KB Output is correct
27 Correct 76 ms 13876 KB Output is correct
28 Correct 123 ms 15872 KB Output is correct
29 Correct 39 ms 15872 KB Output is correct
30 Correct 5 ms 15872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 1436 KB Output is correct
2 Correct 27 ms 1436 KB Output is correct
3 Incorrect 59 ms 1436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 2 ms 524 KB Output is correct
8 Correct 2 ms 524 KB Output is correct
9 Correct 90 ms 1436 KB Output is correct
10 Correct 27 ms 1436 KB Output is correct
11 Incorrect 59 ms 1436 KB Output isn't correct
12 Halted 0 ms 0 KB -