Submission #89353

# Submission time Handle Problem Language Result Execution time Memory
89353 2018-12-12T05:45:33 Z RAkhshon Chessboard (IZhO18_chessboard) C++14
39 / 100
448 ms 9552 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[1111][1111];
int main(){
ios_base::sync_with_stdio(0);
ll n, k;
cin>>n>>k;
for( ll i =1; i <= k ; i ++ ){
    ll a, b;
    cin>>a>>b>>a>>b;
    dp[a][b]=1;
}
ll ans = 1000000000;
for( ll i = 1 ; i*i <= n ; i ++ ){
    if( n % i == 0 ){
        ll m=i, kolp1=0,kolp2=0 ;
        for( ll x = 1; x <= n ; x ++ ){
            for( ll y = 1; y <= n ; y ++ ){

                if( ((x-1)/m)%2==0 && ((y-1)/m)%2 ==0 ) {
                    if( dp[x][y]==0 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2 ==0 && ((y-1)/m)%2 ==1 ) {
                    if( dp[x][y]==1 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2!=0 && ((y-1)/m)%2==0 ) {
                    if( dp[x][y]==1 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2 !=0 && ( (y-1)/m )%2 !=0 ) {
                    if( dp[x][y]==0 ) kolp1++;
                    else
                    kolp2++;
                }
            }
        }
        ans=min(ans,min(kolp1,kolp2));
       m=n/i;kolp1=0;kolp2=0;
       if( m != n ){
        for( ll x = 1; x <= n ; x ++ ){
            for( ll y = 1; y <= n ; y ++ ){

                if( ((x-1)/m)%2==0 && ((y-1)/m)%2 ==0 ) {
                    if( dp[x][y]==0 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2 ==0 && ((y-1)/m)%2 ==1 ) {
                    if( dp[x][y]==1 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2!=0 && ((y-1)/m)%2==0 ) {
                    if( dp[x][y]==1 ) kolp1++;
                    else
                    kolp2++;
                }
                 if( ((x-1)/m)%2 !=0 && ( (y-1)/m )%2 !=0 ) {
                    if( dp[x][y]==0 ) kolp1++;
                    else
                    kolp2++;
                }
            }
        }
///        cout<<ans<<' '<<kolp1<<' '<<kolp2<<endl;
        ans=min(ans,min(kolp1,kolp2));
       }
    }
}
cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 8 ms 568 KB Output is correct
7 Correct 3 ms 568 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1064 KB Output is correct
4 Correct 3 ms 1092 KB Output is correct
5 Correct 3 ms 1092 KB Output is correct
6 Correct 3 ms 1096 KB Output is correct
7 Correct 3 ms 1220 KB Output is correct
8 Correct 3 ms 1220 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 2 ms 1236 KB Output is correct
11 Correct 3 ms 1236 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 3 ms 1236 KB Output is correct
14 Correct 3 ms 1236 KB Output is correct
15 Correct 3 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1064 KB Output is correct
4 Correct 3 ms 1092 KB Output is correct
5 Correct 3 ms 1092 KB Output is correct
6 Correct 3 ms 1096 KB Output is correct
7 Correct 3 ms 1220 KB Output is correct
8 Correct 3 ms 1220 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 2 ms 1236 KB Output is correct
11 Correct 3 ms 1236 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 3 ms 1236 KB Output is correct
14 Correct 3 ms 1236 KB Output is correct
15 Correct 3 ms 1236 KB Output is correct
16 Correct 67 ms 9136 KB Output is correct
17 Correct 65 ms 9536 KB Output is correct
18 Correct 101 ms 9536 KB Output is correct
19 Correct 434 ms 9536 KB Output is correct
20 Correct 448 ms 9536 KB Output is correct
21 Correct 63 ms 9552 KB Output is correct
22 Correct 216 ms 9552 KB Output is correct
23 Correct 131 ms 9552 KB Output is correct
24 Correct 102 ms 9552 KB Output is correct
25 Correct 112 ms 9552 KB Output is correct
26 Correct 79 ms 9552 KB Output is correct
27 Correct 110 ms 9552 KB Output is correct
28 Correct 94 ms 9552 KB Output is correct
29 Correct 37 ms 9552 KB Output is correct
30 Correct 50 ms 9552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 8 ms 568 KB Output is correct
7 Correct 3 ms 568 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Runtime error 3 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -