# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97487 | KLPP | Sajam (COCI18_sajam) | C++14 | 1470 ms | 4188 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;
typedef long long int lld;
int diff(string a, string b){
int ans1=0;
int ans2=0;
for(int i=0;i<a.size();i++){
if(a.at(i)!=b.at(i))ans1++;
else ans2++;
}
return min(ans1,ans2);
}
int main(){
int n,k;
cin>>n>>k;
string table[n];
string table2[n];
int arr[n][n];
for(int i=0;i<n;i++){
cin>>table[i];
for(int j=0;j<n;j++)table2[i]+=table[i].at(j);
table2[i].at(0)='x'+'o'-table[i].at(0);
//cout<<table2[i]<<endl;
}
int ans=1000000000;
for(int i=0;i<n;i++){
int can=0;
int can2=0;
for(int j=0;j<n;j++){
can+=diff(table[i],table[j]);
if(can>k)j=n;
}
for(int j=0;j<n;j++){
can2+=diff(table2[i],table[j]);
if(can2>k)j=n;
}
ans=min(ans,min(can,can2));
if(ans<=k){
cout<<"DA"<<endl;
return 0;
}
}
cout<<"NE"<<endl;
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... |