Submission #1154302

#TimeUsernameProblemLanguageResultExecution timeMemory
1154302arkanefuryChessboard (IZhO18_chessboard)C++20
0 / 100
2095 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define lb lower_bound
#define F first
#define S second
#define sz size()
#define int long long
#define all(v) v.begin(),v.end()
#define FOR1(x, n) for(int j = x; j <= n; j ++)
#define FOR(x, n, m, d) for(int x = n; x <= m; x += d)
#define FORR(x, n, m, d) for(int x = n; x >= m; x -= d)
#define nikita ios_base::sync_with_stdio(0), cin.tie(0);
const int N =  500+5;
int b[N], a[N][N];
int n,m,k,sum=0,x,y, ans, r,pref[N], cnt, l, mod = 1e9+7, cal,lp = 1;
bool used[N];
void solve(){
    cin >> n >> m;
    vector<int>v;
    k = n/2;
    FOR(i, 1, k, 1){
        if(n%i==0)v.pb(i);
    }
        sum = 1e18;
        FOR(ok, 0, v.sz-1, 1){
        bool hi = 0, f = 0;
        ans = 0;
    FOR(i, 1, n, 1){
        FOR(j, 1, n, 1){
            if((j/v[ok])%2 && !hi)ans ++;
        }
        if((i-1)%v[ok]==0 && i != 1)hi ^= 1;
    }
    sum = min({sum, ans, n*n-ans});
    }
    cout << sum;
}
signed main(){
    nikita
    int tt = 1;
    if(!tt)cin >> tt;
    FOR(i, 1, tt, 1)solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...