Submission #493359

# Submission time Handle Problem Language Result Execution time Memory
493359 2021-12-11T06:59:22 Z irmuun Chessboard (IZhO18_chessboard) C++17
70 / 100
298 ms 3400 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define PI 3.14159265359
ll n,m,t,p,h,a,b,c,d,e,f,i,j,k,r,l,mod=1000000007,mod1=998244353,MAX=1e18,ans;
ll X1[100001],X2[100001],Y1[100001],Y2[100001];
string s,u;
ll df[101];
vector<pair<ll,ll> >v;
vector<ll>dv[101];
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            dfs(dv[x][i]);
        }
    }
}
ll fastPow(ll a,ll b){
    ll d=1;
    while(b>0){
        if(b%2==1){
            d=d*a%mod;
        }
        b/=2;
        a=a*a%mod;
    }
    return d;
}
ll check(){
    ll c=n/i;
    ll b,w;
    if(c%2==0){
        b=n*n/2;
        w=b;
    }
    else{
        b=(n-i)*(n+i)/2;
        w=b+(i*i);
    }
    ll num[2]={0};
    for(ll j=1;j<=k;j++){
        num[(((X1[j]-1)/i)+((Y1[j]-1)/i))%2]++;
    }
    return min((w-num[0])+num[1],(b-num[1])+num[0]);
}
int main(){
    cin>>n>>k;
    for(i=1;i<=k;i++){
        cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
    }
    ans=n*n;
    for(i=1;i<n;i++){
        if(n%i==0){
            ans=min(ans,check());
        }
    }
    cout<<ans;
}

Compilation message

chessboard.cpp: In function 'void dfs(long long int)':
chessboard.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(ll i=0;i<dv[x].size();i++){
      |                ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 2228 KB Output is correct
2 Correct 15 ms 716 KB Output is correct
3 Correct 44 ms 1476 KB Output is correct
4 Correct 41 ms 1636 KB Output is correct
5 Correct 58 ms 2004 KB Output is correct
6 Correct 37 ms 1308 KB Output is correct
7 Correct 8 ms 460 KB Output is correct
8 Correct 37 ms 1340 KB Output is correct
9 Correct 100 ms 3080 KB Output is correct
10 Correct 53 ms 1824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 26 ms 1100 KB Output is correct
17 Correct 72 ms 2816 KB Output is correct
18 Correct 80 ms 3360 KB Output is correct
19 Correct 98 ms 3012 KB Output is correct
20 Correct 110 ms 3376 KB Output is correct
21 Correct 69 ms 2712 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 39 ms 1612 KB Output is correct
24 Correct 89 ms 3092 KB Output is correct
25 Correct 8 ms 588 KB Output is correct
26 Correct 46 ms 2064 KB Output is correct
27 Correct 57 ms 2412 KB Output is correct
28 Correct 78 ms 3152 KB Output is correct
29 Correct 28 ms 1224 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 2228 KB Output is correct
2 Correct 15 ms 716 KB Output is correct
3 Correct 44 ms 1476 KB Output is correct
4 Correct 41 ms 1636 KB Output is correct
5 Correct 58 ms 2004 KB Output is correct
6 Correct 37 ms 1308 KB Output is correct
7 Correct 8 ms 460 KB Output is correct
8 Correct 37 ms 1340 KB Output is correct
9 Correct 100 ms 3080 KB Output is correct
10 Correct 53 ms 1824 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 26 ms 1100 KB Output is correct
27 Correct 72 ms 2816 KB Output is correct
28 Correct 80 ms 3360 KB Output is correct
29 Correct 98 ms 3012 KB Output is correct
30 Correct 110 ms 3376 KB Output is correct
31 Correct 69 ms 2712 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 39 ms 1612 KB Output is correct
34 Correct 89 ms 3092 KB Output is correct
35 Correct 8 ms 588 KB Output is correct
36 Correct 46 ms 2064 KB Output is correct
37 Correct 57 ms 2412 KB Output is correct
38 Correct 78 ms 3152 KB Output is correct
39 Correct 28 ms 1224 KB Output is correct
40 Correct 3 ms 332 KB Output is correct
41 Correct 113 ms 2828 KB Output is correct
42 Correct 104 ms 3204 KB Output is correct
43 Correct 107 ms 2868 KB Output is correct
44 Correct 102 ms 3104 KB Output is correct
45 Correct 109 ms 3304 KB Output is correct
46 Correct 123 ms 3140 KB Output is correct
47 Correct 89 ms 3128 KB Output is correct
48 Correct 107 ms 2920 KB Output is correct
49 Correct 90 ms 2792 KB Output is correct
50 Correct 256 ms 3128 KB Output is correct
51 Correct 298 ms 3308 KB Output is correct
52 Correct 265 ms 3068 KB Output is correct
53 Correct 278 ms 3296 KB Output is correct
54 Correct 274 ms 3020 KB Output is correct
55 Correct 288 ms 3400 KB Output is correct
56 Correct 253 ms 3056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 65 ms 2228 KB Output is correct
10 Correct 15 ms 716 KB Output is correct
11 Correct 44 ms 1476 KB Output is correct
12 Correct 41 ms 1636 KB Output is correct
13 Correct 58 ms 2004 KB Output is correct
14 Correct 37 ms 1308 KB Output is correct
15 Correct 8 ms 460 KB Output is correct
16 Correct 37 ms 1340 KB Output is correct
17 Correct 100 ms 3080 KB Output is correct
18 Correct 53 ms 1824 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 26 ms 1100 KB Output is correct
35 Correct 72 ms 2816 KB Output is correct
36 Correct 80 ms 3360 KB Output is correct
37 Correct 98 ms 3012 KB Output is correct
38 Correct 110 ms 3376 KB Output is correct
39 Correct 69 ms 2712 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 39 ms 1612 KB Output is correct
42 Correct 89 ms 3092 KB Output is correct
43 Correct 8 ms 588 KB Output is correct
44 Correct 46 ms 2064 KB Output is correct
45 Correct 57 ms 2412 KB Output is correct
46 Correct 78 ms 3152 KB Output is correct
47 Correct 28 ms 1224 KB Output is correct
48 Correct 3 ms 332 KB Output is correct
49 Correct 113 ms 2828 KB Output is correct
50 Correct 104 ms 3204 KB Output is correct
51 Correct 107 ms 2868 KB Output is correct
52 Correct 102 ms 3104 KB Output is correct
53 Correct 109 ms 3304 KB Output is correct
54 Correct 123 ms 3140 KB Output is correct
55 Correct 89 ms 3128 KB Output is correct
56 Correct 107 ms 2920 KB Output is correct
57 Correct 90 ms 2792 KB Output is correct
58 Correct 256 ms 3128 KB Output is correct
59 Correct 298 ms 3308 KB Output is correct
60 Correct 265 ms 3068 KB Output is correct
61 Correct 278 ms 3296 KB Output is correct
62 Correct 274 ms 3020 KB Output is correct
63 Correct 288 ms 3400 KB Output is correct
64 Correct 253 ms 3056 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Incorrect 0 ms 204 KB Output isn't correct
67 Halted 0 ms 0 KB -