#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#ifdef LOCAL
#include "23.h"
#endif
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
bool isblack(int blok, int x, int y){
return (((x/blok)%2)^((y/blok)%2));
}
int32_t main(){
ios;
int t=1;
int tno = 0;
if (!t) cin>>t;
while (t-(tno++)){
deci(n);deci(k);
vector<pair<pair<int,int>,pair<int,int>>> arr(k);
int all = 0;
for (int i = 0; i < k; i++){
cin>>arr[i].first.first>>arr[i].second.first>>arr[i].first.second>>arr[i].second.second;
arr[i].first.first--;
arr[i].first.second--;
arr[i].second.first--;
arr[i].second.second--;
all+=(arr[i].second.second-arr[i].second.first+1)*(arr[i].first.second-arr[i].first.first+1);
assert((arr[i].second.second-arr[i].second.first+1)*(arr[i].first.second-arr[i].first.first+1)==1);
}
int ans = MOD;
for (int i = 1; i < n; i++){
if (n%i) continue;
assert(i!=1);
int say = 0;
for (int j = 0; j < k; j++){
for (int z = arr[j].first.first; z <= arr[j].first.second; z++){
for (int tt = arr[j].second.first; tt<=arr[j].second.second;tt++){
say+=isblack(i,z,tt);
}
}
}
int blk = n*n/2;
int whit = n*n-blk;
ans=min(ans,min(blk-say+all-say,say+whit-(all-say)));
}
cout<<ans<<endl;
}
}
Compilation message
chessboard.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
4472 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
4472 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |