Submission #208389

#TimeUsernameProblemLanguageResultExecution timeMemory
208389ArKCaMarko (COCI15_marko)C++17
50 / 50
33 ms1528 KiB
#include<bits/stdc++.h> #define pb push_back #define fri(a) freopen(a,"r",stdin); #define fro(a) freopen(a,"w",stdout); using namespace std; int n; string s; vector<string>v; int hesap(int i,int j){ if(s[i]=='2'){ if(v[j][i]=='a' || v[j][i]=='b' || v[j][i]=='c' ) return 1; } if(s[i]=='3'){ if(v[j][i]=='d' || v[j][i]=='e' || v[j][i]=='f' ) return 1; } if(s[i]=='4'){ if(v[j][i]=='g' || v[j][i]=='h' || v[j][i]=='i' ) return 1; } if(s[i]=='5'){ if(v[j][i]=='j' || v[j][i]=='k' || v[j][i]=='l' ) return 1; } if(s[i]=='6'){ if(v[j][i]=='m' || v[j][i]=='n' || v[j][i]=='o' ) return 1; } if(s[i]=='7'){ if(v[j][i]=='p' || v[j][i]=='q' || v[j][i]=='r' || v[j][i]=='s' ) return 1; } if(s[i]=='8'){ if(v[j][i]=='t' || v[j][i]=='u' || v[j][i]=='v' ) return 1; } if(s[i]=='9'){ if(v[j][i]=='w' || v[j][i]=='x' || v[j][i]=='y' || v[j][i]=='z') return 1; } return 0; } int main(){ //fri("in.txt"); //fro("out.txt"); cin>>n;/**/ for(int i=0;i<n;i++){ cin>>s; v.pb(s); } cin>>s; sort(v.begin(), v.end()); int alt=0,ust=n-1; for(int i=0;i<s.size();++i){ for(int j=alt;j<=ust;j++){ if(hesap(i,j)==1){ alt=j; break; } } for(int j=ust;j>=alt;j--){ if(hesap(i,j)==1){ ust=j; break; } } } int ans=0; for(int i=alt;i<=ust;i++){ if(v[i].size()==s.size()){ // printf("%d\n", i); ans++; } } cout<<ans<<endl; }

Compilation message (stderr)

marko.cpp: In function 'int main()':
marko.cpp:57:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();++i){
              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...