#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;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
//ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//vector<ll> edge[1234567];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
ll res = 1;
while (val) {
if (val % 2 == 1) {
res = res * base;
}
base = base * base;
base %= mod;
res %= mod;
val /= 2;
}
return res;
}
bool comp(pl x,pl y){
if(x.ff>y.ff)return true;
return false;
}
ll find(ll x){
if(x==par[x])return x;
else return par[x]=find(par[x]);
}
pl findnum(ll x){
ll res = x*x;
ll l = n/x;
l*=l;
if(l%2==1){
return {res*(l/2+1) , res*((l/2))};
}
else{
return {res*(l/2) , res*((l/2))};
}
}
bool check(ll x,ll y,ll k){
ll res = (x+k-1)/k + (y-1+k)/k;
if(res%2==1)return false;
else return true;
}
class A {
public:
static void funcA() {
cin>>n>>m;
vl vec;
for(int i=1;i<n;i++){
if(n%i==0){
vec.pb(i);
}
}
map<ll,pl> mp;
map<ll,pl> mpp;
for(auto u:vec){
mpp[u] = findnum(u);
//cout<<u<<" "<<mpp[u].ff<<" "<<mpp[u].ss<<'\n';
}
for(int i=1;i<=m;i++){
ll x,y,xx,yy;
cin>>x>>y>>xx>>yy;
for(auto u:vec){
if(check(x,y,u)==1){
mp[u].ff++;
}
else mp[u].ss++;
}
}
ans=MAX;
for(auto u:vec){
ll res = mpp[u].ff - mp[u].ff + mp[u].ss;
res=min(res , mpp[u].ss - mp[u].ss + mp[u].ff);
/*cout<<u<<'\n';
cout<<mpp[u].ff<<" "<<mpp[u].ss<<'\n';
cout<<mp[u].ff<<" "<<mp[u].ss<<'\n';*/
ans=min(ans,res);
}
cout<<ans<<'\n';
}
}lol;
void solve() {
A::funcA();
}
int main() {
ll T = 1;
//cin>>T;
boost;
while (T--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
292 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
296 KB |
Output is correct |
2 |
Correct |
17 ms |
332 KB |
Output is correct |
3 |
Correct |
38 ms |
332 KB |
Output is correct |
4 |
Correct |
40 ms |
416 KB |
Output is correct |
5 |
Correct |
54 ms |
368 KB |
Output is correct |
6 |
Correct |
34 ms |
408 KB |
Output is correct |
7 |
Correct |
8 ms |
332 KB |
Output is correct |
8 |
Correct |
42 ms |
516 KB |
Output is correct |
9 |
Correct |
89 ms |
452 KB |
Output is correct |
10 |
Correct |
55 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
23 ms |
716 KB |
Output is correct |
17 |
Correct |
73 ms |
1548 KB |
Output is correct |
18 |
Correct |
79 ms |
1796 KB |
Output is correct |
19 |
Correct |
108 ms |
1676 KB |
Output is correct |
20 |
Correct |
124 ms |
1800 KB |
Output is correct |
21 |
Correct |
64 ms |
1544 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
38 ms |
912 KB |
Output is correct |
24 |
Correct |
92 ms |
1684 KB |
Output is correct |
25 |
Correct |
10 ms |
332 KB |
Output is correct |
26 |
Correct |
44 ms |
1188 KB |
Output is correct |
27 |
Correct |
54 ms |
1300 KB |
Output is correct |
28 |
Correct |
76 ms |
1800 KB |
Output is correct |
29 |
Correct |
30 ms |
828 KB |
Output is correct |
30 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
296 KB |
Output is correct |
2 |
Correct |
17 ms |
332 KB |
Output is correct |
3 |
Correct |
38 ms |
332 KB |
Output is correct |
4 |
Correct |
40 ms |
416 KB |
Output is correct |
5 |
Correct |
54 ms |
368 KB |
Output is correct |
6 |
Correct |
34 ms |
408 KB |
Output is correct |
7 |
Correct |
8 ms |
332 KB |
Output is correct |
8 |
Correct |
42 ms |
516 KB |
Output is correct |
9 |
Correct |
89 ms |
452 KB |
Output is correct |
10 |
Correct |
55 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
300 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
308 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
23 ms |
716 KB |
Output is correct |
27 |
Correct |
73 ms |
1548 KB |
Output is correct |
28 |
Correct |
79 ms |
1796 KB |
Output is correct |
29 |
Correct |
108 ms |
1676 KB |
Output is correct |
30 |
Correct |
124 ms |
1800 KB |
Output is correct |
31 |
Correct |
64 ms |
1544 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
38 ms |
912 KB |
Output is correct |
34 |
Correct |
92 ms |
1684 KB |
Output is correct |
35 |
Correct |
10 ms |
332 KB |
Output is correct |
36 |
Correct |
44 ms |
1188 KB |
Output is correct |
37 |
Correct |
54 ms |
1300 KB |
Output is correct |
38 |
Correct |
76 ms |
1800 KB |
Output is correct |
39 |
Correct |
30 ms |
828 KB |
Output is correct |
40 |
Correct |
3 ms |
332 KB |
Output is correct |
41 |
Correct |
134 ms |
2264 KB |
Output is correct |
42 |
Correct |
97 ms |
2448 KB |
Output is correct |
43 |
Correct |
108 ms |
2244 KB |
Output is correct |
44 |
Correct |
110 ms |
2448 KB |
Output is correct |
45 |
Correct |
97 ms |
2580 KB |
Output is correct |
46 |
Correct |
140 ms |
2476 KB |
Output is correct |
47 |
Correct |
87 ms |
2316 KB |
Output is correct |
48 |
Correct |
113 ms |
2324 KB |
Output is correct |
49 |
Correct |
90 ms |
2180 KB |
Output is correct |
50 |
Correct |
422 ms |
2452 KB |
Output is correct |
51 |
Correct |
482 ms |
2584 KB |
Output is correct |
52 |
Correct |
430 ms |
2452 KB |
Output is correct |
53 |
Correct |
448 ms |
2504 KB |
Output is correct |
54 |
Correct |
433 ms |
2416 KB |
Output is correct |
55 |
Correct |
485 ms |
2576 KB |
Output is correct |
56 |
Correct |
404 ms |
2456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
292 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
73 ms |
296 KB |
Output is correct |
10 |
Correct |
17 ms |
332 KB |
Output is correct |
11 |
Correct |
38 ms |
332 KB |
Output is correct |
12 |
Correct |
40 ms |
416 KB |
Output is correct |
13 |
Correct |
54 ms |
368 KB |
Output is correct |
14 |
Correct |
34 ms |
408 KB |
Output is correct |
15 |
Correct |
8 ms |
332 KB |
Output is correct |
16 |
Correct |
42 ms |
516 KB |
Output is correct |
17 |
Correct |
89 ms |
452 KB |
Output is correct |
18 |
Correct |
55 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
300 KB |
Output is correct |
29 |
Correct |
1 ms |
304 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
308 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
23 ms |
716 KB |
Output is correct |
35 |
Correct |
73 ms |
1548 KB |
Output is correct |
36 |
Correct |
79 ms |
1796 KB |
Output is correct |
37 |
Correct |
108 ms |
1676 KB |
Output is correct |
38 |
Correct |
124 ms |
1800 KB |
Output is correct |
39 |
Correct |
64 ms |
1544 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
38 ms |
912 KB |
Output is correct |
42 |
Correct |
92 ms |
1684 KB |
Output is correct |
43 |
Correct |
10 ms |
332 KB |
Output is correct |
44 |
Correct |
44 ms |
1188 KB |
Output is correct |
45 |
Correct |
54 ms |
1300 KB |
Output is correct |
46 |
Correct |
76 ms |
1800 KB |
Output is correct |
47 |
Correct |
30 ms |
828 KB |
Output is correct |
48 |
Correct |
3 ms |
332 KB |
Output is correct |
49 |
Correct |
134 ms |
2264 KB |
Output is correct |
50 |
Correct |
97 ms |
2448 KB |
Output is correct |
51 |
Correct |
108 ms |
2244 KB |
Output is correct |
52 |
Correct |
110 ms |
2448 KB |
Output is correct |
53 |
Correct |
97 ms |
2580 KB |
Output is correct |
54 |
Correct |
140 ms |
2476 KB |
Output is correct |
55 |
Correct |
87 ms |
2316 KB |
Output is correct |
56 |
Correct |
113 ms |
2324 KB |
Output is correct |
57 |
Correct |
90 ms |
2180 KB |
Output is correct |
58 |
Correct |
422 ms |
2452 KB |
Output is correct |
59 |
Correct |
482 ms |
2584 KB |
Output is correct |
60 |
Correct |
430 ms |
2452 KB |
Output is correct |
61 |
Correct |
448 ms |
2504 KB |
Output is correct |
62 |
Correct |
433 ms |
2416 KB |
Output is correct |
63 |
Correct |
485 ms |
2576 KB |
Output is correct |
64 |
Correct |
404 ms |
2456 KB |
Output is correct |
65 |
Correct |
0 ms |
204 KB |
Output is correct |
66 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |