답안 #169433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169433 2019-12-20T10:31:14 Z RafaelSus Chessboard (IZhO18_chessboard) C++14
70 / 100
279 ms 7032 KB
#include <bits/stdc++.h>
 
using namespace std;
const int N = 1e5 + 5;
typedef long long ll;
const ll inf=1e18+18ll;
#define pb push_back
 
ll n,k;
ll a[N];

vector<int> J[N];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  
  
  int n;
  cin>>n>>k;
  /*if(k==0){
    cout<<(n*1ll*n/2ll)<<'\n';
    return 0;
  }*/
  for(int i=0;i<k;i++){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    J[y1].push_back(n-x1+1);
  }
  vector<int> div;div.push_back(1);
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      div.push_back(i);
      if(n/i!=i)div.push_back(n/i);
    }
  }
  sort(div.begin(),div.end());
  ll answ=n*1ll*n;
  for(int i=0;i<div.size();i++){
    ll tmp=0ll;
    //cerr<<div[i]<<' ';
    ll x=n/div[i];
    if(x%2){ll y=x/2+1,z=x/2;tmp=y*y+z*z;}
    else{ll y=x/2;tmp=y*y+y*y;}
    tmp=tmp*1ll*div[i]*1ll*div[i];//cerr<<tmp<<' ';
    for(int j=1;j<=n;j++){//cerr<<tmp<<' ';
      for(int p=0;p<J[j].size();p++){
        if(j%div[i]==0){
          if((j/div[i])%2){
            if(J[j][p]%div[i]==0){
              if((J[j][p]/div[i])%2){
                tmp--;
              }else tmp++;
            }else if((J[j][p]/div[i])%2==0){
              tmp--;
            }else tmp++;
          }else{
            if(J[j][p]%div[i]==0){
              if((J[j][p]/div[i])%2==0){
                tmp--;
              }else tmp++;
            }else if((J[j][p]/div[i])%2==1){
              tmp--;
            }else tmp++;
          }
        }else if((j/div[i])%2==0){
          if(J[j][p]%div[i]==0){
            if((J[j][p]/div[i])%2){
              tmp--;
            }else tmp++;
          }else if((J[j][p]/div[i])%2==0){
            tmp--;
          }else tmp++;
        }else if((j/div[i])%2==1){
          if(J[j][p]%div[i]==0){
            if((J[j][p]/div[i])%2==0){
              tmp--;
            }else tmp++;
          }else if((J[j][p]/div[i])%2==1){
            tmp--;
          }else tmp++;
        }
      }//cerr<<tmp<<' ';
    }
    answ=min(answ,min(tmp,n*1ll*n-tmp));
    //cerr<<answ<<'\n';
  }
  cout<<answ<<'\n';
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<div.size();i++){
               ~^~~~~~~~~~~
chessboard.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int p=0;p<J[j].size();p++){
                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2732 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 3960 KB Output is correct
2 Correct 13 ms 3320 KB Output is correct
3 Correct 28 ms 4600 KB Output is correct
4 Correct 24 ms 3832 KB Output is correct
5 Correct 35 ms 5040 KB Output is correct
6 Correct 24 ms 4348 KB Output is correct
7 Correct 8 ms 3064 KB Output is correct
8 Correct 25 ms 4344 KB Output is correct
9 Correct 53 ms 5880 KB Output is correct
10 Correct 31 ms 4728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 15 ms 3320 KB Output is correct
17 Correct 36 ms 4576 KB Output is correct
18 Correct 44 ms 4856 KB Output is correct
19 Correct 55 ms 4856 KB Output is correct
20 Correct 59 ms 4856 KB Output is correct
21 Correct 34 ms 4728 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 24 ms 3832 KB Output is correct
24 Correct 39 ms 4700 KB Output is correct
25 Correct 8 ms 2936 KB Output is correct
26 Correct 26 ms 3960 KB Output is correct
27 Correct 31 ms 4344 KB Output is correct
28 Correct 41 ms 4728 KB Output is correct
29 Correct 17 ms 3448 KB Output is correct
30 Correct 5 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 3960 KB Output is correct
2 Correct 13 ms 3320 KB Output is correct
3 Correct 28 ms 4600 KB Output is correct
4 Correct 24 ms 3832 KB Output is correct
5 Correct 35 ms 5040 KB Output is correct
6 Correct 24 ms 4348 KB Output is correct
7 Correct 8 ms 3064 KB Output is correct
8 Correct 25 ms 4344 KB Output is correct
9 Correct 53 ms 5880 KB Output is correct
10 Correct 31 ms 4728 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2732 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 5 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 15 ms 3320 KB Output is correct
27 Correct 36 ms 4576 KB Output is correct
28 Correct 44 ms 4856 KB Output is correct
29 Correct 55 ms 4856 KB Output is correct
30 Correct 59 ms 4856 KB Output is correct
31 Correct 34 ms 4728 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 24 ms 3832 KB Output is correct
34 Correct 39 ms 4700 KB Output is correct
35 Correct 8 ms 2936 KB Output is correct
36 Correct 26 ms 3960 KB Output is correct
37 Correct 31 ms 4344 KB Output is correct
38 Correct 41 ms 4728 KB Output is correct
39 Correct 17 ms 3448 KB Output is correct
40 Correct 5 ms 2808 KB Output is correct
41 Correct 104 ms 6416 KB Output is correct
42 Correct 79 ms 6876 KB Output is correct
43 Correct 78 ms 6524 KB Output is correct
44 Correct 68 ms 6776 KB Output is correct
45 Correct 63 ms 7032 KB Output is correct
46 Correct 101 ms 6920 KB Output is correct
47 Correct 56 ms 6520 KB Output is correct
48 Correct 78 ms 6648 KB Output is correct
49 Correct 58 ms 6520 KB Output is correct
50 Correct 279 ms 6620 KB Output is correct
51 Correct 275 ms 6776 KB Output is correct
52 Correct 264 ms 6616 KB Output is correct
53 Correct 274 ms 6780 KB Output is correct
54 Correct 261 ms 6520 KB Output is correct
55 Correct 273 ms 7004 KB Output is correct
56 Correct 252 ms 6520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2732 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 40 ms 3960 KB Output is correct
10 Correct 13 ms 3320 KB Output is correct
11 Correct 28 ms 4600 KB Output is correct
12 Correct 24 ms 3832 KB Output is correct
13 Correct 35 ms 5040 KB Output is correct
14 Correct 24 ms 4348 KB Output is correct
15 Correct 8 ms 3064 KB Output is correct
16 Correct 25 ms 4344 KB Output is correct
17 Correct 53 ms 5880 KB Output is correct
18 Correct 31 ms 4728 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2732 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 4 ms 2680 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 5 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 4 ms 2680 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 15 ms 3320 KB Output is correct
35 Correct 36 ms 4576 KB Output is correct
36 Correct 44 ms 4856 KB Output is correct
37 Correct 55 ms 4856 KB Output is correct
38 Correct 59 ms 4856 KB Output is correct
39 Correct 34 ms 4728 KB Output is correct
40 Correct 4 ms 2680 KB Output is correct
41 Correct 24 ms 3832 KB Output is correct
42 Correct 39 ms 4700 KB Output is correct
43 Correct 8 ms 2936 KB Output is correct
44 Correct 26 ms 3960 KB Output is correct
45 Correct 31 ms 4344 KB Output is correct
46 Correct 41 ms 4728 KB Output is correct
47 Correct 17 ms 3448 KB Output is correct
48 Correct 5 ms 2808 KB Output is correct
49 Correct 104 ms 6416 KB Output is correct
50 Correct 79 ms 6876 KB Output is correct
51 Correct 78 ms 6524 KB Output is correct
52 Correct 68 ms 6776 KB Output is correct
53 Correct 63 ms 7032 KB Output is correct
54 Correct 101 ms 6920 KB Output is correct
55 Correct 56 ms 6520 KB Output is correct
56 Correct 78 ms 6648 KB Output is correct
57 Correct 58 ms 6520 KB Output is correct
58 Correct 279 ms 6620 KB Output is correct
59 Correct 275 ms 6776 KB Output is correct
60 Correct 264 ms 6616 KB Output is correct
61 Correct 274 ms 6780 KB Output is correct
62 Correct 261 ms 6520 KB Output is correct
63 Correct 273 ms 7004 KB Output is correct
64 Correct 252 ms 6520 KB Output is correct
65 Correct 4 ms 2680 KB Output is correct
66 Incorrect 4 ms 2680 KB Output isn't correct
67 Halted 0 ms 0 KB -