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;
string arr[1005];
bitset<1005> bit[1005];
int co[1005];
int n,k;
int main()
{
cin >> n >> k;
for(int i=0;i<n;i++)
{
cin >> arr[i];
for(int j=0;j<n;j++)
{
arr[i][j]=(arr[i][j]=='o'?'1':'0');
}
bit[i]=bitset<1005>(arr[i]);
}
for(int i=0;i<n;i++)
{
int cur=0;
for(int j=0;j<n;j++)
{
int z=(bit[i]^bit[j]).count();
cur+=min(z,n-z);
}
if(cur<=k)
{
cout << "DA" << endl;
return 0;
}
}
bitset<1005> b=bit[0];
for(int i=0;i<n;i++)
{
b[i]=(1-b[i]);
int cur=0;
for(int j=0;j<n;j++)
{
int z=(b^bit[j]).count();
cur+=min(z,n-z);
}
if(cur<=k)
{
cout << "DA" << endl;
return 0;
}
b[i]=(1-b[i]);
}
cout << "NE" << endl;
}
# | 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... |