/** kutbilim.one **/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
/*
ifstream in("test.txt");
#define cin in */
const int MAX = 1010;
int n, k;
int a[MAX][MAX];
bool isprime(int n){
if(n == 2) return true;
for(int i = 2; i*i <= n; i++)
if(n%i == 0) return false;
return true;
}
void solve_1(){
int cnt[2] = {INT_MAX, INT_MAX};
for(int i = 1; i <= n; i++){
if(n % i) continue;
if(i%2 == 0){
cnt[0] = min(cnt[0], (i*i)/2);
cnt[1] = min(cnt[1], (i*i)/2);
}else{
cnt[0] = min(cnt[0], (i*i)/2);
cnt[1] = min(cnt[1], (i*i)/2+1);
}
}
cout << min(cnt[0], cnt[1]);
}
void solve_2(){
for(int i = 1; i <= k; i++){
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
for(int x = x1; x <= x2; x++)
for(int y = y1; y <= y2; y++){
a[x][y] = 1;
}
}
int cnt[2] = {};
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
cnt[0] += a[i][j] == (i+j)%2;
cnt[1] += a[i][j] != (i+j)%2;
}
}
cout << min(cnt[1], cnt[0]) << endl;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
if(k == 0){
solve_1();
}else if(isprime(n)){
solve_2();
}else if(n <= 1000){
// solve_3_4();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 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 |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 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 |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |