# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
165409 |
2019-11-27T06:35:29 Z |
egekabas |
Marko (COCI15_marko) |
C++14 |
|
46 ms |
376 KB |
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<ll, ll> pii;
typedef pair<ld, ld> pld;
int n;
map<ll, ll> mpp;
string s;
vector<int> v;
void change(string s){
v.clear();
for(auto u : s){
if(u == 'a')
v.pb(2);
if(u == 'b'){
v.pb(2);
//v.pb(2);
}
if(u == 'c'){
v.pb(2);
}
if(u == 'd')
v.pb(3);
if(u == 'e'){
v.pb(3);
}
if(u == 'f'){
v.pb(3);
}
if(u == 'g')
v.pb(4);
if(u == 'h'){
v.pb(4);
}
if(u == 'i'){
v.pb(4);
}
if(u == 'j')
v.pb(5);
if(u == 'k'){
v.pb(5);
}
if(u == 'l'){
v.pb(5);
}
if(u == 'm')
v.pb(6);
if(u == 'n'){
v.pb(6);
}
if(u == 'o'){
v.pb(6);
}
if(u == 'p')
v.pb(7);
if(u == 'q'){
v.pb(7);
}
if(u == 'r'){
v.pb(7);
}
if(u == 's'){
v.pb(7);
}
if(u == 't')
v.pb(8);
if(u == 'u'){
v.pb(8);
}
if(u == 'v'){
v.pb(8);
}
if(u == 'w')
v.pb(9);
if(u == 'x'){
v.pb(9);
}
if(u == 'y'){
v.pb(9);
}
if(u == 'z'){
v.pb(9);
}
}
}
ll calc(){
ll mod = 1e9+7;
ll p = 31;
ll mult = 31;
ll ret = 0;
for(auto u : v){
ret += u*mult%mod;
mult *= p;
ret %= mod;
}
return ret;
}
int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n;
for(int i = 0; i < n; ++i){
cin >> s;
change(s);
++mpp[calc()];
}
char c;
v.clear();
while(scanf("%c", &c) != EOF){
if(c >= '0' && c <= '9')
v.pb((int)c-(int)'0');
}
cout << mpp[calc()] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
43 ms |
376 KB |
Output is correct |
5 |
Correct |
22 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
296 KB |
Output is correct |
7 |
Correct |
26 ms |
376 KB |
Output is correct |
8 |
Correct |
46 ms |
376 KB |
Output is correct |
9 |
Correct |
8 ms |
376 KB |
Output is correct |
10 |
Correct |
33 ms |
376 KB |
Output is correct |