#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e18, P=998244353;
int q=1, n, m, x, y, c, l, r, k, a[N], f[N], ansl, ansr, ans, o, u, Ans;
string s;
bitset<1000> b[1000];
int xorr(bitset<1000> x, bitset<1000> y){return min((int)(x^y).count(), (int)(n-(x^y).count()));}
int solve(int i){
int ans=0;
for (int j=0; j<n; j++)ans+=xorr(b[i],b[j]);
}
main(){ios_base::sync_with_stdio(false), cin.tie(0);
cin>>n>>k;
Ans=INF;
for (int i=0; i<n; i++){
cin>>s;
int j=0;
for(auto c:s)b[i][j++]=(c=='x');
}
for (int i=0; i<n; i++)Ans=min(solve(i), Ans);
if(k==n){
for (int i=0; i<n; i++){
b[0][i].flip();
Ans=min(solve(0)+1, Ans);
b[0][i].flip();
}
}
puts((Ans<=k) ? "DA":"NE");
}
/*
3 2
xxo
xox
oxx
*/
Compilation message
sajam.cpp: In function 'int solve(int)':
sajam.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
20 | }
| ^
sajam.cpp: At global scope:
sajam.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
| ^~~~
sajam.cpp: In function 'int main()':
sajam.cpp:24:9: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
24 | Ans=INF;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
420 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
692 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
716 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |