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 ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,minn;
bitset<1000> A[1000];
string s[1003];
ll xorr(bitset<1000> x, bitset<1000> y){return min((ll)(x^y).count(), (ll)(n-(x^y).count()));}
ll go(ll x) {
ll cur=0;
for(ll i=1;i<=n;i++) {
if(i==x) continue;
cur+=xorr(A[i],A[x]);
}
return cur;
}
int main() {
cin>>n>>k;
for(ll i=1;i<=n;i++) {
cin>>s[i];
for(ll j=0;j<s[i].size();j++) {
A[i][j]=(s[i][j]=='x');
}
}
minn=1e18;
for(ll i=1;i<=n;i++) {
minn=min(minn,go(i));
}
if(n==k) {
for(ll j=0;j<n;j++) {
if(A[1][j]==0) A[1][j]=1;
else A[1][j]=0;
minn=min(minn,go(1)+1);
if(A[1][j]==0) A[1][j]=1;
else A[1][j]=0;
}
}
if(minn<=k) cout<<"DA";
else cout<<"NE";
}
Compilation message (stderr)
sajam.cpp: In function 'int main()':
sajam.cpp:23:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(ll j=0;j<s[i].size();j++) {
| ~^~~~~~~~~~~~
# | 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... |