# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105131 | arthur_nascimento | Sajam (COCI18_sajam) | C++14 | 322 ms | 6484 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 1010
#define bs bitset<maxn>
#define debug
int ans = 0;
bs col[maxn];
char M[maxn][maxn];
int dif[maxn][maxn];
void go(int n,int k){
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
col[j].set(i,M[i][j] == 'x');
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
dif[i][j] = (col[i] ^ col[j]).count();
for(int j=0;j<n;j++){
int s = 0;
for(int jj=0;jj<n;jj++)
s += min(dif[j][jj],n-dif[j][jj]);
if(s <= k)
ans = 1;
}
debug("%d\n",ans);
}
int main(){
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
scanf(" %c",&M[i][j]);
go(n,k);
for(int i=0;i<n;i++)
for(int j=i;j<n;j++)
swap(M[i][j], M[j][i]);
go(n,k);
for(int i=0;i<n;i++){
int s = 1;
for(int j=1;j<n;j++){
int d = dif[0][j];
if(M[i][0] == M[i][j])
d++;
else
d--;
s += min(d,n-d);
}
if(s <= k){
ans = 1;
debug("i %d s %d\n",i,s);
}
}
if(ans)
printf("DA\n");
else
printf("NE\n");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |