Submission #624195

# Submission time Handle Problem Language Result Execution time Memory
624195 2022-08-07T12:22:17 Z MilosMilutinovic Marko (COCI15_marko) C++14
50 / 50
18 ms 1444 KB
/**
 *    author:  wxhtzdy
 *    created: 07.08.2022 14:13:41
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  map<char, char> key;
  key['a'] = key['b'] = key['c'] = '2';
  key['d'] = key['e'] = key['f'] = '3';
  key['g'] = key['h'] = key['i'] = '4';
  key['j'] = key['k'] = key['l'] = '5';
  key['m'] = key['n'] = key['o'] = '6';
  key['p'] = key['q'] = key['r'] = key['s'] = '7';
  key['t'] = key['u'] = key['v'] = '8';
  key['w'] = key['x'] = key['y'] = key['z'] = '9';
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < (int) s[i].size(); j++) {
      s[i][j] = key[s[i][j]];
    }
  }
  sort(s.begin(), s.end());
  string str;
  cin >> str;
  int L = lower_bound(s.begin(), s.end(), str) - s.begin();
  if (L >= n || L < 0 || s[L] != str) {
    cout << 0 << '\n';
    return 0;
  }             
  str.back() += 1;
  int R = lower_bound(s.begin(), s.end(), str) - s.begin();
  cout << R - L << '\n';  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 16 ms 1324 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 10 ms 852 KB Output is correct
8 Correct 18 ms 1444 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 13 ms 1104 KB Output is correct