#include <bits/stdc++.h>
#define ll long long
ll n, k, x, y, xx, yy;
ll d;
bool used[150][150], pr = false;
using namespace std;
int main()
{
cin >> n >> k;
for ( int i = 1; i <= k; i ++ ) {
cin >> x >> y >> xx >> yy;
used[x][y] = true;
}
ll cn = 0;
for ( int i = 1; i <= n; i ++ ) {
if ( n % i == 0 ) cn ++;
}
if ( cn == 2 ) {
ll ans = 0, ans1 = 0;
for ( int i = 1; i <= n; i ++ ) {
for ( int j = 1; j <= n; j ++ ) {
if ( i % 2 == 1 ) {
if ( j % 2 == 1 ) {
if ( !used[i][j] ) ans ++;
}
else {
if ( used[i][j] ) ans ++;
}
}
if ( i % 2 == 0 ) {
if ( j % 2 == 0 ) {
if ( !used[i][j] ) ans ++;
}
else {
if ( used[i][j] ) ans ++;
}
}
}
}
for ( int i = 1; i <= n; i ++ ) {
for ( int j = 1; j <= n; j ++ ) {
if ( i % 2 == 1 ) {
if ( j % 2 == 0 ) {
if ( !used[i][j] ) ans1 ++;
}
else {
if ( used[i][j] ) ans1 ++;
}
}
if ( i % 2 == 0 ) {
if ( j % 2 == 1 ) {
if ( !used[i][j] ) ans1 ++;
}
else {
if ( used[i][j] ) ans1 ++;
}
}
}
}
cout << min ( ans, ans1 );
return 0;
}
for ( int i = n-1; i >= 1; i -- ) {
if ( n % i == 0 ) {
d = i;
break;
}
}
if ( d == 1 ) {
cout << (n*n) / 2;
}
else {
ll cnt = 0;
bool ch = false;
for ( int i = 1; i <= n; i += d ) {
ch = !ch;
if ( ch ) {
cnt += ( n / d ) / 2;
}
else {
cnt += ( n / d + 1 ) / 2;
}
}
cout << cnt * (d*d);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |