Submission #878087

# Submission time Handle Problem Language Result Execution time Memory
878087 2023-11-24T04:55:42 Z _unknown_2010 Chessboard (IZhO18_chessboard) C++17
16 / 100
21 ms 460 KB
//#ifndef LOCAL
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#endif

#include <bits/stdc++.h>
using namespace std;
using vecp = vector<pair<int,int>>;
#define vecm(a,n,m) vector<vector<int>>a(n,vector<int>(m,0));
#define int int64_t
#define pb  push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mpii map<int,int>
#define lb lower_bound
#define ub upper_bound
#define foor(i,a,b) for(int i=a;i<b; i++)
#define foor(i,a) foor(i,0,a)
#define ins insert
#define ss second
#define ff first
#define until(x, a) for (auto x : a)
#define ln(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define seea(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
const int mod = 1E9+7;
bool tub(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i==0)return false;
    }
    return true;
}
void solution(){
    int n,k;
    cin >> n >> k;
    if(k>0){
        int f=n/2*(n/2+1)*2;
    int s=(n/2+1)*(n/2+1)+(n/2)*(n/2);
    while(k--){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;
        if(a%2==b%2){
            s--;f++;
        }
        else {
            s++;f--;
        }
    }
    cout << min(s,f);
    }
    else {
        vector<int> mx;
    for(int i=1; i<=n/2; i++){
        if(n%i==0){
            int x=n/i;
            if(x%2==0){
                mx.push_back((i*i)*x/2*n);
            }
            else {
                mx.pb(x/2*(x/2+1)*2*(i*i));
            }
        }
    }
    sort(all(mx));
    cout << mx[0];
    }
}
int32_t main(){
    clock_t tStart = clock();
    std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1; // cin >> q;
    while(q--) {
        solution();
        cout << '\n';
    }
    cerr<<fixed<<setprecision(3)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
}
/*

██╗  ██╗ █████╗  ██████╗     ██╗██╗   ██╗ ██████╗████████╗
██║░░██║██╔══██╗██╔════╝░░░░░██║██║░░░██║██╔════╝╚══██╔══╝
███████║██║░░██║╚█████╗░░░░░░██║██║░░░██║╚█████╗░░░░██║░░░
██╔══██║██║░░██║░╚═══██╗██╗░░██║██║░░░██║░╚═══██╗░░░██║░░░
██║░░██║╚█████╔╝██████╔╝╚█████╔╝╚██████╔╝██████╔╝░░░██║░░░
╚═╝░░╚═╝░╚════╝░╚═════╝░░╚════╝░░╚═════╝░╚═════╝░░░░╚═╝░░░
*/

Compilation message

chessboard.cpp:19: warning: "foor" redefined
   19 | #define foor(i,a) foor(i,0,a)
      | 
chessboard.cpp:18: note: this is the location of the previous definition
   18 | #define foor(i,a,b) for(int i=a;i<b; i++)
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 460 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 16 ms 452 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Correct 2 ms 452 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 21 ms 348 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 460 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 16 ms 452 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Correct 2 ms 452 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 21 ms 348 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Incorrect 0 ms 344 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 14 ms 460 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 10 ms 348 KB Output is correct
13 Correct 16 ms 452 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 2 ms 452 KB Output is correct
16 Correct 9 ms 348 KB Output is correct
17 Correct 21 ms 348 KB Output is correct
18 Correct 11 ms 348 KB Output is correct
19 Incorrect 0 ms 344 KB Output isn't correct
20 Halted 0 ms 0 KB -