Submission #334337

# Submission time Handle Problem Language Result Execution time Memory
334337 2020-12-09T03:38:05 Z beksultan04 Chessboard (IZhO18_chessboard) C++14
0 / 100
37 ms 3968 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int resh[N],ans[N],n;
vector <int> v[N];
int fun(int x){
    int i,j,ans=0,cnt=0,res=(n*n+1)/2,c=1;
    for (i=1;i<=n;++i){
        for (j=0;j<v[i].size();++j){
            int y = v[i][j]/x;
            if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--;
            else res++;
        }
        cnt++;
        if (cnt % x == 0)
            c++;
    }

    ret min((res),n*n-res);
}

main(){
    int k,i,j;
    vector <int> pr;
    scan2(n,k)

    while (k--){
        int x1,x2,y1,y2;
        scan2(x1,y1)
        scan2(x2,y2)
        v[x1].pb(y1);
    }
    /// ///////////////////////
    for (i=2;i*i<=n;++i){
        if (n%i==0){
            pr.pb(i);
            if (i*i != n)pr.pb(n/i);
        }
    }
    int ans=fun(1);
    for (i=0;i<pr.size();++i){
        ans = min(ans,fun(pr[i]));
    }
    cout <<ans;

}


















Compilation message

chessboard.cpp: In function 'long long int fun(long long int)':
chessboard.cpp:21:19: 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]
   21 |         for (j=0;j<v[i].size();++j){
      |                  ~^~~~~~~~~~~~
chessboard.cpp:23:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |             if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--;
      |                 ~~~~~~~~~^~~~~~~~~~~
chessboard.cpp:19:13: warning: unused variable 'ans' [-Wunused-variable]
   19 |     int i,j,ans=0,cnt=0,res=(n*n+1)/2,c=1;
      |             ^~~
chessboard.cpp: At global scope:
chessboard.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      |      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:53:15: 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]
   53 |     for (i=0;i<pr.size();++i){
      |              ~^~~~~~~~~~
chessboard.cpp:35:13: warning: unused variable 'j' [-Wunused-variable]
   35 |     int k,i,j;
      |             ^
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:37:5: note: in expansion of macro 'scan2'
   37 |     scan2(n,k)
      |     ^~~~~
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:41:9: note: in expansion of macro 'scan2'
   41 |         scan2(x1,y1)
      |         ^~~~~
chessboard.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:42:9: note: in expansion of macro 'scan2'
   42 |         scan2(x2,y2)
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 2 ms 2668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 2 ms 2668 KB Output isn't correct
3 Halted 0 ms 0 KB -