# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208389 | ArKCa | Marko (COCI15_marko) | C++17 | 33 ms | 1528 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 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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |