Submission #92874

# Submission time Handle Problem Language Result Execution time Memory
92874 2019-01-05T11:49:34 Z muradeyn Chessboard (IZhO18_chessboard) C++14
39 / 100
246 ms 2060 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<intt>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 (intt 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 26 ms 1344 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 1 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 Correct 2 ms 380 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 3 ms 376 KB Output is correct
14 Correct 2 ms 376 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 1 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 Correct 2 ms 380 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 3 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 16 ms 888 KB Output is correct
17 Correct 29 ms 1816 KB Output is correct
18 Correct 51 ms 2060 KB Output is correct
19 Correct 219 ms 1912 KB Output is correct
20 Correct 246 ms 2040 KB Output is correct
21 Correct 29 ms 1656 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 36 ms 1144 KB Output is correct
24 Correct 46 ms 1912 KB Output is correct
25 Correct 9 ms 632 KB Output is correct
26 Correct 29 ms 1276 KB Output is correct
27 Correct 46 ms 1528 KB Output is correct
28 Correct 49 ms 1912 KB Output is correct
29 Correct 12 ms 1016 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1344 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 26 ms 1344 KB Output isn't correct
10 Halted 0 ms 0 KB -