Submission #208391

# Submission time Handle Problem Language Result Execution time Memory
208391 2020-03-11T06:31:36 Z DysonSphere Marko (COCI15_marko) C++14
50 / 50
39 ms 1020 KB
#include<bits/stdc++.h>
using namespace std;
/*
1
2 abc
3 def
4 ghi
5 jkl
6 mno
7 pqrs
8 tuv
9 wxyz
*/
set<char> key[10];
int main(){
	key[2].insert('a');
	key[2].insert('b');
	key[2].insert('c');

	key[3].insert('d');
	key[3].insert('e');
	key[3].insert('f');

	key[4].insert('g');
	key[4].insert('h');
	key[4].insert('i');

	key[5].insert('j');
	key[5].insert('k');
	key[5].insert('l');

	key[6].insert('m');
	key[6].insert('n');
	key[6].insert('o');

	key[7].insert('p');
	key[7].insert('q');
	key[7].insert('r');
	key[7].insert('s');

	key[8].insert('t');
	key[8].insert('u');
	key[8].insert('v');

	key[9].insert('w');
	key[9].insert('x');
	key[9].insert('y');
	key[9].insert('z');

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,ans=0;
	cin>>n;
	string pres;
	vector<string> v;
	for(int i=0;i<n;i++){
		cin>>pres;
		v.push_back(pres);
	}
	sort(v.begin(), v.end());
	cin>>pres;
	for(int i=0;i<v.size();i++){
		if(pres.size()!=v[i].size()){
			continue;
		}
		for(int j=0;j<v[i].size();j++){
			if(key[pres[j]-48].find(v[i][j])==key[pres[j]-48].end()){
				break;
			}
			if(j==v[i].size()-1){
				ans++;
			}
		}
	}
	cout<<ans;
}

Compilation message

marko.cpp: In function 'int main()':
marko.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
marko.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<v[i].size();j++){
               ~^~~~~~~~~~~~
marko.cpp:70:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j==v[i].size()-1){
       ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 34 ms 888 KB Output is correct
5 Correct 8 ms 376 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 19 ms 632 KB Output is correct
8 Correct 39 ms 1020 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 26 ms 760 KB Output is correct