#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 1e5+777;
const int MOD = 1e9+7;
vector<int> div(int x){
vector<int> res = {1};
for(int i = 2; i * i <= x; ++i){
if(x % i == 0){
res.pb(i);
if(x / i != i)
res.pb(x/i);
}
}
sort(all(res));
return res;
}
struct block{
int x1, y1, x2, y2;
void read(){
cin >> x1 >> y1 >> x2 >> y2;
}
}a[N];
int n, k, cnt[N][2];
int get1(){
int cnt1 = n * n / 2 + (n & 1);
int cnt2 = n * n - cnt1;
int sum1 = 0, sum2 = 0;
for(int i = 1; i <= n; ++i){
if(i & 1){
sum1 += cnt[i][1];
sum2 += cnt[i][0];
}else{
sum1 += cnt[i][0];
sum2 += cnt[i][1];
}
}
return min(cnt1 - sum1 + sum2, cnt2 - sum2 + cnt1);
}
int get2(vector<int> &d){
return -1;
}
int main(){auto solve=[&](){
cin >> n >> k;
for(int i = 1; i <= k; ++i){
a[i].read();
++cnt[N][a[i].y1&1];
}
vector<int> d = div(n);
if(sz(d) == 1){
cout << get1() << '\n';
}else{
cout << get2(d);
}
};NFS;solve();}
Compilation message
chessboard.cpp: In function 'int main()':
chessboard.cpp:66:10: warning: array subscript 100777 is above array bounds of 'int [100777][2]' [-Warray-bounds]
66 | ++cnt[N][a[i].y1&1];
| ~~~~~^
chessboard.cpp:43:11: note: while referencing 'cnt'
43 | int n, k, cnt[N][2];
| ^~~
chessboard.cpp:66:10: warning: array subscript 100777 is above array bounds of 'int [100777][2]' [-Warray-bounds]
66 | ++cnt[N][a[i].y1&1];
| ~~~~~^
chessboard.cpp:43:11: note: while referencing 'cnt'
43 | int n, k, cnt[N][2];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
2444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
2444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |