#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
int n,k;
int aa,bb,cc,dd;
vector<pair<int,int>> cur;
int check(int nn){
if(nn==n){
return n*n;
}
int co;
if((n/nn)%2==0){
co=(n*n)/2;
}
else{
co=(n*n-nn*nn)/2;
}
//cout<<co<<":";
for(auto i:cur){
if((i.a/nn+i.b/nn)%2==1){
co-=1;
}
else{
co+=1;
}
}
int co2;
if((n/nn)%2==0){
co2=(n*n)/2;
}
else{
co2=(n*n+nn*nn)/2;
}
// cout<<co2<<endl;
for(auto i:cur){
if((i.a/nn+i.b/nn)%2==0){
co2-=1;
}
else{
co2+=1;
}
}
// cout<<nn<<","<<co<<","<<co2<<endl;
return min(co,co2);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>k;
for(int i=0;i<k;i++){
cin>>aa>>bb>>cc>>dd;
aa-=1;
bb-=1;
cur.pb({aa,bb});
}
int ans=n*n;
for(int i=1;i*i<=n;i++){
if(n%i==0){
ans=min(ans,check(i));
ans=min(ans,check(n/i));
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
2556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
15 ms |
1280 KB |
Output is correct |
17 |
Correct |
31 ms |
2812 KB |
Output is correct |
18 |
Correct |
41 ms |
2912 KB |
Output is correct |
19 |
Correct |
90 ms |
2812 KB |
Output is correct |
20 |
Correct |
99 ms |
2828 KB |
Output is correct |
21 |
Correct |
29 ms |
2812 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
24 ms |
1664 KB |
Output is correct |
24 |
Correct |
42 ms |
2812 KB |
Output is correct |
25 |
Correct |
9 ms |
640 KB |
Output is correct |
26 |
Correct |
27 ms |
1792 KB |
Output is correct |
27 |
Correct |
32 ms |
2684 KB |
Output is correct |
28 |
Correct |
42 ms |
2812 KB |
Output is correct |
29 |
Correct |
17 ms |
1536 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
2556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Incorrect |
32 ms |
2556 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |