답안 #340278

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340278 2020-12-27T11:27:27 Z scales Chessboard (IZhO18_chessboard) C++17
39 / 100
80 ms 1900 KB
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
using namespace std;
int main()
{
      ios::sync_with_stdio(false);
      cin.tie(0);
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
     cin>>n;
     cin>>k;
     z=0;
     maxi=1000000000;
     vector<long long> a(k),b(k);
     for(i=0;i<k;i++)
     {
         cin>>a[i];
         cin>>b[i];
         cin>>x;
         cin>>y;
         a[i]--;
         b[i]--;
     }
     vector<long long> viv;
     for(i=2;i<n;i++)
     {
         if(n%i==0)
         {
             viv.push_back(i);
         }
     }
     viv.push_back(1);
     x=viv.size();
        for(i=0;i<x;i++)
        {
             kol=0;
             w=viv[i];
             //cout<<"w="<<w<<endl;
             for(j=0;j<k;j++)
             {
                 //cout<<"a="<<a[j]<<" b="<<b[j]<<" "<<a[j]%(2*w)<<" "<<b[j]%(2*w)<<endl;
                 if( ((a[j]%(2*w)<w) && (b[j]%(2*w)>=w)) ||((a[j]%(2*w)>=w) && (b[j]%(2*w)<w)))
                 {
                     kol++;
                 }
             }
             v=(n*n)/(w*w);
             if(v%2==0)
             {
                 f=n*n/2;
                 s=n*n/2;
             }
             else
             {
                 s=(n*n-w*w)/2;
                 f=n*n-s;
             }
             kol=k-kol;
             //cout<<"kol="<<kol<<" f="<<f<<" s="<<s<<" maxi=";
             maxi=min({maxi,(f-kol+k-kol),(kol+s-k+kol)});
             //cout<<maxi<<endl;
        }
        cout<<maxi<<endl;


    return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:15:16: warning: unused variable 't' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                ^
chessboard.cpp:15:22: warning: unused variable 'dno' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                      ^~~
chessboard.cpp:15:30: warning: variable 'z' set but not used [-Wunused-but-set-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                              ^
chessboard.cpp:15:34: warning: unused variable 'm' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                  ^
chessboard.cpp:15:40: warning: unused variable 'x1' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                        ^~
chessboard.cpp:15:43: warning: unused variable 'tip' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                           ^~~
chessboard.cpp:15:47: warning: unused variable 'g' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                               ^
chessboard.cpp:15:49: warning: unused variable 'p' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                 ^
chessboard.cpp:15:51: warning: unused variable 'l' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                   ^
chessboard.cpp:15:53: warning: unused variable 'r' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                     ^
chessboard.cpp:15:55: warning: unused variable 'sum' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,tip,g,p,l,r,sum,maxi,kol,v,f,s;
      |                                                       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 1260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 748 KB Output is correct
17 Correct 32 ms 1644 KB Output is correct
18 Correct 36 ms 1900 KB Output is correct
19 Correct 73 ms 1780 KB Output is correct
20 Correct 80 ms 1900 KB Output is correct
21 Correct 27 ms 1644 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 19 ms 1004 KB Output is correct
24 Correct 33 ms 1772 KB Output is correct
25 Correct 4 ms 492 KB Output is correct
26 Correct 22 ms 1260 KB Output is correct
27 Correct 28 ms 1388 KB Output is correct
28 Correct 37 ms 1772 KB Output is correct
29 Correct 11 ms 876 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 1260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 25 ms 1260 KB Output isn't correct
10 Halted 0 ms 0 KB -