Submission #1154358

#TimeUsernameProblemLanguageResultExecution timeMemory
1154358arkanefuryChessboard (IZhO18_chessboard)C++20
70 / 100
89 ms456 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); } FOR(i, 0, v.sz-1, 1){ k = n / v[i]; if(k%2==0)b[i] = (k/2) * v[i]*v[i] * k; else{ b[i] = ((k+1)/2) * v[i] * v[i] * ((k+1)/2); b[i] += (k/2) * v[i]*v[i] * (k/2); } } FOR(i, 1, m, 1){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; x1--,y1--; FOR(j, 0, v.sz-1, 1){ x = x1 / v[j], y = y1 / v[j]; if(x % 2 == y % 2)b[j]--; else b[j]++; } } ans = 1e18; FOR(j, 0, v.sz-1, 1){ if(b[j])ans = min({ans, b[j], n*n-b[j]}); } cout << ans; } 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...