#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#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 _34raRxL ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
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...);
}
}
#define yare {cout<<"DA\n"; exit(0);}
#define nare {cout<<"NE\n"; exit(0);}
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;
signed main(){
_34raRxL;
int n,k;
cin>>n>>k;
int 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]=='o';
}
}
vec(vi) tbl(2*n,vi(2*n));
rep(i,h){
rep(j,w){
int x=a[i][j];
// co = j + n ..
int ro=i,co=j+n;
tbl[ro][co]=tbl[co][ro]=x;
}
}
vi c(n);
{
rep(i,n){
rep(j,n){
c[i]+=(tbl[i][j+n]!=tbl[0][j+n]);
}
}
}
{
vec(vi) rbe(n,vi(2));
rep(i,n){
rep(j,n){
bool e=(2*c[i]<n);
if(tbl[i][j+n]!=tbl[0][j+n]){
rbe[j][e]++;
}else{
rbe[j][e^1]++;
}
}
}
int now=0;
rep(i,n){
now+=min(rbe[i][0],rbe[i][1]);
}
if(now<=k){
yare;
}
}
nare;
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
3956 KB |
Output is correct |
3 |
Correct |
6 ms |
5708 KB |
Output is correct |
4 |
Correct |
21 ms |
17320 KB |
Output is correct |
5 |
Correct |
7 ms |
5980 KB |
Output is correct |
6 |
Correct |
3 ms |
2500 KB |
Output is correct |
7 |
Correct |
7 ms |
5432 KB |
Output is correct |
8 |
Correct |
24 ms |
18172 KB |
Output is correct |
9 |
Correct |
2 ms |
1352 KB |
Output is correct |
10 |
Correct |
24 ms |
18476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
292 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
11972 KB |
Output is correct |
2 |
Correct |
15 ms |
14644 KB |
Output is correct |
3 |
Correct |
11 ms |
9932 KB |
Output is correct |
4 |
Correct |
9 ms |
8708 KB |
Output is correct |
5 |
Correct |
18 ms |
17096 KB |
Output is correct |
6 |
Correct |
7 ms |
6368 KB |
Output is correct |
7 |
Correct |
14 ms |
11680 KB |
Output is correct |
8 |
Correct |
14 ms |
12648 KB |
Output is correct |
9 |
Correct |
5 ms |
3660 KB |
Output is correct |
10 |
Correct |
26 ms |
20548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
15944 KB |
Output is correct |
2 |
Correct |
17 ms |
15532 KB |
Output is correct |
3 |
Correct |
12 ms |
8924 KB |
Output is correct |
4 |
Correct |
13 ms |
11384 KB |
Output is correct |
5 |
Correct |
13 ms |
12172 KB |
Output is correct |
6 |
Correct |
22 ms |
19688 KB |
Output is correct |
7 |
Correct |
5 ms |
4940 KB |
Output is correct |
8 |
Correct |
13 ms |
11052 KB |
Output is correct |
9 |
Correct |
15 ms |
12164 KB |
Output is correct |
10 |
Correct |
26 ms |
20532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
9016 KB |
Output is correct |
2 |
Correct |
9 ms |
9152 KB |
Output is correct |
3 |
Correct |
22 ms |
20260 KB |
Output is correct |
4 |
Correct |
8 ms |
6476 KB |
Output is correct |
5 |
Correct |
12 ms |
9164 KB |
Output is correct |
6 |
Correct |
21 ms |
19592 KB |
Output is correct |
7 |
Correct |
6 ms |
6128 KB |
Output is correct |
8 |
Correct |
7 ms |
6888 KB |
Output is correct |
9 |
Correct |
8 ms |
7060 KB |
Output is correct |
10 |
Correct |
8 ms |
6836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
20944 KB |
Output is correct |
2 |
Correct |
22 ms |
19908 KB |
Output is correct |
3 |
Correct |
19 ms |
18340 KB |
Output is correct |
4 |
Correct |
12 ms |
11212 KB |
Output is correct |
5 |
Correct |
12 ms |
11356 KB |
Output is correct |
6 |
Correct |
14 ms |
11972 KB |
Output is correct |
7 |
Correct |
7 ms |
6344 KB |
Output is correct |
8 |
Correct |
17 ms |
16136 KB |
Output is correct |
9 |
Correct |
12 ms |
8996 KB |
Output is correct |
10 |
Correct |
25 ms |
19268 KB |
Output is correct |