Submission #153719

# Submission time Handle Problem Language Result Execution time Memory
153719 2019-09-15T12:47:19 Z BabinSinko Marko (COCI15_marko) C++14
50 / 50
35 ms 1400 KB
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <string>
#include <vector>

using namespace std;

long long n, x, sol, l;

vector <string> w;
string s, a;

int main(){

cin >> n;
for (int i = 0; i < n; i++){
	cin >> a;
	w.push_back(a);
}
cin >> s;
sol = n;
l = s.length();
for (int i = 0; i < l; i++){
	if (s[i] == '2'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'a' and w[j][i] != 'b' and w[j][i] != 'c'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '3'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'd' and w[j][i] != 'e' and w[j][i] != 'f'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '4'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'g' and w[j][i] != 'h' and w[j][i] != 'i'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '5'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'j' and w[j][i] != 'k' and w[j][i] != 'l'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '6'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'm' and w[j][i] != 'n' and w[j][i] != 'o'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '7'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'p' and w[j][i] != 'q' and w[j][i] != 'r' and w[j][i] != 's'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '8'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 't' and w[j][i] != 'u' and w[j][i] != 'v'){
				w.erase(w.begin() + j);
				n = n - 1;
				j = j - 1;
			}	
		}	
	}
	if (s[i] == '9'){
		for (int j = 0; j < n; j++){
			if (w[j][i] != 'w' and w[j][i] != 'x' and w[j][i] != 'y' and w[j][i] != 'z'){
				w.erase(w.begin() + j);
				n = n - 1;;
				j = j - 1;
			}	
		}	
	}
}
cout << n;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 33 ms 1272 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 20 ms 936 KB Output is correct
8 Correct 35 ms 1400 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 24 ms 1016 KB Output is correct