#pragma GCC optimize("unroll-loops,O3")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
bitset <1005> bs[1005];
char getc() {
char ch;
cin >> ch;
return ch;
}
int dist(bitset <1005> &a, bitset <1005> &b) {
return (a ^ b).count();
}
#define ONLINE_JUDGE
void solve() {
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
bs[i][j] = (getc() == 'o');
}
}
for(int i = 1; i <= n; i++) {
int tot = 0;
for(int j = 1; j <= n; j++) {
int c = dist(bs[i], bs[j]);
tot += min(c, n - c);
}
if(tot <= k) {
return cout << "DA" << "\n", void();
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
bs[i][j] = bs[i][j] ^ 1;
int tot = 0;
for(int j = 1; j <= n; j++) {
int c = dist(bs[i], bs[j]);
tot += min(c, n - c);
}
if(tot <= k -1) {
return cout << "DA" << "\n", void();
}
bs[i][j] = bs[i][j] ^ 1;
}
}
cout << "NE";
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
348 KB |
Output is correct |
4 |
Correct |
12 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
650 ms |
496 KB |
Output is correct |
8 |
Correct |
4283 ms |
1396 KB |
Output is correct |
9 |
Correct |
64 ms |
348 KB |
Output is correct |
10 |
Correct |
4363 ms |
1416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
11 ms |
348 KB |
Output is correct |
3 |
Correct |
7 ms |
496 KB |
Output is correct |
4 |
Correct |
6 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
496 KB |
Output is correct |
6 |
Correct |
848 ms |
520 KB |
Output is correct |
7 |
Correct |
2180 ms |
1096 KB |
Output is correct |
8 |
Correct |
2444 ms |
1128 KB |
Output is correct |
9 |
Correct |
347 ms |
644 KB |
Output is correct |
10 |
Execution timed out |
5029 ms |
1340 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
348 KB |
Output is correct |
3 |
Correct |
7 ms |
348 KB |
Output is correct |
4 |
Correct |
10 ms |
760 KB |
Output is correct |
5 |
Correct |
9 ms |
348 KB |
Output is correct |
6 |
Correct |
4768 ms |
556 KB |
Output is correct |
7 |
Correct |
635 ms |
716 KB |
Output is correct |
8 |
Correct |
2055 ms |
1032 KB |
Output is correct |
9 |
Correct |
2334 ms |
1112 KB |
Output is correct |
10 |
Execution timed out |
5028 ms |
1372 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
600 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
25 ms |
348 KB |
Output is correct |
4 |
Correct |
10 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
348 KB |
Output is correct |
6 |
Correct |
4702 ms |
556 KB |
Output is correct |
7 |
Correct |
787 ms |
776 KB |
Output is correct |
8 |
Correct |
948 ms |
828 KB |
Output is correct |
9 |
Correct |
1018 ms |
836 KB |
Output is correct |
10 |
Correct |
942 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Output is correct |
2 |
Correct |
18 ms |
348 KB |
Output is correct |
3 |
Correct |
22 ms |
564 KB |
Output is correct |
4 |
Correct |
14 ms |
556 KB |
Output is correct |
5 |
Correct |
11 ms |
348 KB |
Output is correct |
6 |
Correct |
2250 ms |
528 KB |
Output is correct |
7 |
Correct |
868 ms |
792 KB |
Output is correct |
8 |
Correct |
3548 ms |
1300 KB |
Output is correct |
9 |
Correct |
1375 ms |
924 KB |
Output is correct |
10 |
Correct |
4628 ms |
1452 KB |
Output is correct |