Submission #928622

# Submission time Handle Problem Language Result Execution time Memory
928622 2024-02-16T19:25:17 Z jpfr12 ZigZag (COCI17_zigzag) C++17
80 / 80
59 ms 12912 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
 
typedef long long ll;
typedef unsigned long long int ull;
using namespace std;
int MOD = (int)1e9+7;
int MAXN = 1e6;
 
//classes
 
 
 
//global
int n, m;
map<char, vector<string>> Map;
vector<int> total(26, 0);
vector<int> pos(26, 0);

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //ifstream fin("longpath.in");
  //ofstream fout("longpath.out");
  //stop
  cin >> n >> m;
  vector<string> names(n);
  for(string& i: names){
    cin >> i;
    total[i[0]-'a']++;
  }
  sort(names.begin(), names.end());
  for(string& i: names){
    Map[i[0]].push_back(i);
  }
  for(int i = 0; i < m; i++){
    char c;
    cin >> c;
    cout << Map[c][pos[c-'a']] << '\n';
    pos[c-'a']++;
    pos[c-'a'] %= total[c-'a'];
  }
  return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 420 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 49 ms 12680 KB Output is correct
8 Correct 59 ms 12912 KB Output is correct
9 Correct 49 ms 12880 KB Output is correct
10 Correct 55 ms 12848 KB Output is correct