Submission #92865

# Submission time Handle Problem Language Result Execution time Memory
92865 2019-01-05T11:30:47 Z muradeyn Chessboard (IZhO18_chessboard) C++14
39 / 100
105 ms 3448 KB
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);

using namespace std;

struct rect{
    int a , b , c , d;
};

rect sub[SIZE];

intt need;

vector<intt>ans;

int n , k;

vector<int>dv;

int main()
{
    FAST_READ;
    cin>>n>>k;
    for (int i = 0;i<k;i++)cin>>sub[i].a>>sub[i].b>>sub[i].c>>sub[i].d;
    dv.push_back(1);
    for (int i = 2;i * i <= n;i++) {
        if (n % i == 0) {
            dv.push_back(i);
            if (i * i == n)continue;
            dv.push_back(n / i);
        }
    }
    for (int i : dv) {
        need = ( (n / i + 1) / 2 ) * ( (n / i + 1) / 2 );
        need += (n / i / 2) * (n / i / 2);
        need *= (i * i);
        for (int j = 0;j < k;j++) {
            int row , column;
            if (sub[j].a % i == 0)row = sub[j].a / i;
            else row = (sub[j].a + i) / i;
            if (sub[j].b % i == 0)column = sub[j].b / i;
            else column = (sub[j].b + i) / i;
            if (row % 2 == column % 2) need--;
            else need++;
        }
        ans.push_back(need);
        need = ( (n / i + 1) / 2 ) * ( (n / i + 1) / 2 );
        need += (n / i / 2) * (n / i / 2);
        need *= (i * i);
        need = n * n - need;
        for (int j = 0;j < k;j++) {
            int row , column;
            if (sub[j].a % i == 0)row = sub[j].a / i;
            else row = (sub[j].a + i) / i;
            if (sub[j].b % i == 0)column = sub[j].b / i;
            else column = (sub[j].b + i) / i;
            if (row % 2 == column % 2) need++;
            else need--;
        }
        ans.push_back(need);
    }
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
    return 0;
}
# Verdict Execution time Memory 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 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
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 372 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 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory 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 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 372 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 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 12 ms 1272 KB Output is correct
17 Correct 27 ms 2936 KB Output is correct
18 Correct 37 ms 3448 KB Output is correct
19 Correct 95 ms 3192 KB Output is correct
20 Correct 105 ms 3448 KB Output is correct
21 Correct 25 ms 2936 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 23 ms 1656 KB Output is correct
24 Correct 33 ms 3192 KB Output is correct
25 Correct 6 ms 632 KB Output is correct
26 Correct 21 ms 2172 KB Output is correct
27 Correct 31 ms 2552 KB Output is correct
28 Correct 36 ms 3448 KB Output is correct
29 Correct 11 ms 1400 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 Incorrect 24 ms 1400 KB Output isn't correct
10 Halted 0 ms 0 KB -