# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575303 | AGE | Sajam (COCI18_sajam) | C++14 | 2871 ms | 3212 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 int long long
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=1e6,M=3e3+2,mod=1e9+7;
string s[M];
main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>s[i];
for(int i=0;i<n;i++){
int ans=0;
for(int j=0;j<n;j++){
if(i==j)
continue;
int cnt=0;
for(int k=0;k<n;k++)
cnt+=(s[i][k]!=s[j][k]);
int cnt2=0;
for(int k=0;k<n;k++)
cnt2+=(s[i][k]==s[j][k]);
ans+=min(cnt,cnt2);
}
if(ans<=m){
cout<<"DA"<<endl;
return 0;
}
}
for(int i=0;i<n;i++){
if(s[0][i]=='x')
s[0][i]='o';
else
s[0][i]='x';
int ans=0;
for(int j=1;j<n;j++){
int cnt=0;
for(int k=0;k<n;k++)
cnt+=(s[0][k]!=s[j][k]);
int cnt2=0;
for(int k=0;k<n;k++)
cnt2+=(s[0][k]==s[j][k]);
ans+=min(cnt,cnt2);
}
if(s[0][i]=='x')
s[0][i]='o';
else
s[0][i]='x';
if(ans<=m){
cout<<"DA"<<endl;
return 0;
}
}
cout<<"NE"<<endl;
}
///use scanf
///+963 998 452 343
/*
8 8
xxxxoooo
xoxoxoxo
xxxxoooo
xoxoxoxo
xxxxoooo
xoxoxoxo
xxxxoooo
xoxoxoxo
*/
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... |