Submission #44068

# Submission time Handle Problem Language Result Execution time Memory
44068 2018-03-29T14:09:06 Z Nordway Chessboard (IZhO18_chessboard) C++14
0 / 100
93 ms 1384 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;
int n, k;
void solve(int v){
    ll d = n / v;
    ll l = ((d / 2) * (d / 2) + (d / 2 + 1) * (d / 2 + 1)) * v * v;
    ll r = ((d / 2) * (d / 2 + 1) + (d / 2 + 1) * (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){
            r--;
            l++;
        }
        else{
            r++;
            l--;
        }
    }
    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 1384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 1384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -