# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102456 | BanFcc | Sajam (COCI18_sajam) | C++14 | 85 ms | 5376 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>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
void test(){cerr<<"\n";}
template<typename T,typename... Args>void test(T x,Args... args){cerr<<x<<" ";test(args...);}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)1e5+5;
const int MOD=(int)1e9+7;
char str[1005];
bitset<1005>b[1005];
int a[1005][1005];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
scanf("%s",str);
for(int j=0;j<n;j++){
b[i][j]=(str[j]=='o');
}
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
a[i][j]=a[j][i]=n-(b[i]^b[j]).count();
}
}
int flag=0;
for(int i=1;i<=n;i++){
int stp=0;
for(int j=1;j<=n;j++){
if(i==j)continue;
stp+=min(n-a[i][j],a[i][j]);
}
if(stp<=k){
flag=1;
break;
}
}
if(k==n&&flag==0){
for(int i=0;i<n;i++){
int f=1;
for(int j=2;j<=n;j++){
int tmp=a[1][j];
if(b[1][i]!=b[j][i])tmp++;
else tmp--;
if(tmp!=1&&tmp!=n-1)f=0;
}
if(f){
flag=1;
break;
}
}
}
if(flag)printf("DA\n");
else printf("NE\n");
return 0;
}
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... |