#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _343tk3a ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
void print(){cout<<"\n";}
template<class te,class ...ti>
void print(const te&v,const ti&...nv){cout<<v;if(sizeof...(nv)){cout<<" ";print(nv...);}}
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
//e
int main(){
_343tk3a;
int n,k;
cin>>n>>k;
int h,w;
h=n,w=n;
vec(vi) a(h,vi(w));
rep(i,h){
string s;
cin>>s;
rep(j,w){
a[i][j]=(s[j]=='x');
}
}
vec(vi) oa;
oa=a;
auto af=[&](vi _a){
a=oa;
rep(j,w){
if(_a[j]){
rep(_i,h){
a[_i][j]^=1;
}
}
}
int res=0;
rep(i,h){
int c=0;
rep(j,w)c+=a[i][j];
res+=min(c,n-c);
}
return res;
};
int res=n+1;
rep(i,h){
res=min(res,af(a[i]));
rep(j,w)a[i][j]^=1;
res=min(res,af(a[i]));
rep(j,w)a[i][j]^=1;
}
print((res<=k?"DA":"NO"),"\n");
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
319 ms |
1912 KB |
Output is correct |
3 |
Correct |
603 ms |
2680 KB |
Output is correct |
4 |
Correct |
3525 ms |
7664 KB |
Output is correct |
5 |
Correct |
616 ms |
2736 KB |
Output is correct |
6 |
Correct |
141 ms |
1232 KB |
Output is correct |
7 |
Incorrect |
545 ms |
2524 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Incorrect |
4 ms |
316 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1834 ms |
5324 KB |
Output is correct |
2 |
Correct |
2694 ms |
6484 KB |
Output is correct |
3 |
Correct |
1541 ms |
4448 KB |
Output is correct |
4 |
Correct |
1221 ms |
3928 KB |
Output is correct |
5 |
Correct |
3883 ms |
7544 KB |
Output is correct |
6 |
Incorrect |
759 ms |
2896 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3203 ms |
7032 KB |
Output is correct |
2 |
Correct |
3198 ms |
6844 KB |
Output is correct |
3 |
Correct |
1244 ms |
4068 KB |
Output is correct |
4 |
Correct |
1877 ms |
5112 KB |
Output is correct |
5 |
Correct |
2059 ms |
5456 KB |
Output is correct |
6 |
Incorrect |
4727 ms |
8632 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1384 ms |
4056 KB |
Output is correct |
2 |
Correct |
1248 ms |
4120 KB |
Output is correct |
3 |
Incorrect |
4896 ms |
8920 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5049 ms |
9092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |