Submission #208389

# Submission time Handle Problem Language Result Execution time Memory
208389 2020-03-11T06:11:43 Z ArKCa Marko (COCI15_marko) C++17
50 / 50
33 ms 1528 KB
#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

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 time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 33 ms 1400 KB Output is correct
5 Correct 8 ms 504 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 19 ms 888 KB Output is correct
8 Correct 31 ms 1528 KB Output is correct
9 Correct 8 ms 504 KB Output is correct
10 Correct 23 ms 1016 KB Output is correct