#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 1005
bitset<N> arr[N];
int dist[N][N];
const int INF = 2e9 + 7;
int32_t main(){
#ifndef ONLINE_JUDGE
//fileio();
#endif
fastio();
int n, k;
cin>>n>>k;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
char c;
cin>>c;
arr[i][j] = c == 'x';
}
}
for (int i = 1; i <= n; i++){
for (int j = i + 1; j <= n; j++){
bitset<N> tmp = arr[i] ^ arr[j];
dist[i][j] = dist[j][i] = tmp.count();
}
}
int ans = INF;
for (int i = 1; i <= n; i++){
int curr = 0;
for (int j = 1; j <= n; j++){
curr += min(dist[i][j], n - dist[i][j]);
}
ans = min(ans, curr);
}
if (ans <= k) cout<<"DA\n";
else cout<<"NE\n";
//cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
8 ms |
2132 KB |
Output is correct |
3 |
Correct |
12 ms |
2600 KB |
Output is correct |
4 |
Correct |
41 ms |
4252 KB |
Output is correct |
5 |
Correct |
15 ms |
2644 KB |
Output is correct |
6 |
Correct |
5 ms |
1748 KB |
Output is correct |
7 |
Correct |
11 ms |
2492 KB |
Output is correct |
8 |
Correct |
36 ms |
4316 KB |
Output is correct |
9 |
Correct |
3 ms |
1236 KB |
Output is correct |
10 |
Correct |
37 ms |
4368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
3624 KB |
Output is correct |
2 |
Correct |
28 ms |
3936 KB |
Output is correct |
3 |
Correct |
21 ms |
3276 KB |
Output is correct |
4 |
Correct |
17 ms |
3144 KB |
Output is correct |
5 |
Correct |
33 ms |
4116 KB |
Output is correct |
6 |
Correct |
12 ms |
2660 KB |
Output is correct |
7 |
Correct |
24 ms |
3544 KB |
Output is correct |
8 |
Correct |
25 ms |
3716 KB |
Output is correct |
9 |
Correct |
7 ms |
2064 KB |
Output is correct |
10 |
Correct |
41 ms |
4528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4028 KB |
Output is correct |
2 |
Correct |
30 ms |
3984 KB |
Output is correct |
3 |
Correct |
18 ms |
3192 KB |
Output is correct |
4 |
Correct |
23 ms |
3516 KB |
Output is correct |
5 |
Correct |
23 ms |
3648 KB |
Output is correct |
6 |
Correct |
38 ms |
4508 KB |
Output is correct |
7 |
Correct |
9 ms |
2368 KB |
Output is correct |
8 |
Correct |
21 ms |
3412 KB |
Output is correct |
9 |
Correct |
24 ms |
3636 KB |
Output is correct |
10 |
Correct |
41 ms |
4644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
3204 KB |
Output is correct |
2 |
Correct |
18 ms |
3156 KB |
Output is correct |
3 |
Incorrect |
41 ms |
4568 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
4656 KB |
Output is correct |
2 |
Correct |
40 ms |
4428 KB |
Output is correct |
3 |
Incorrect |
35 ms |
4308 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |