Submission #97487

#TimeUsernameProblemLanguageResultExecution timeMemory
97487KLPPSajam (COCI18_sajam)C++14
90 / 90
1470 ms4188 KiB
#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)

sajam.cpp: In function 'int diff(std::__cxx11::string, std::__cxx11::string)':
sajam.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a.size();i++){
              ~^~~~~~~~~
sajam.cpp: In function 'int main()':
sajam.cpp:20:6: warning: unused variable 'arr' [-Wunused-variable]
  int arr[n][n];
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...