답안 #1025797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025797 2024-07-17T10:14:18 Z vjudge1 ZigZag (COCI17_zigzag) C++17
80 / 80
161 ms 6420 KB
#include<bits/stdc++.h>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<string > v[26];
  for(int i = 0; i < n; i ++)
    {
      string s;
      cin >> s;
      v[s[0] - 'a'].push_back(s);
    }

  for(int i =0 ; i < 26; i ++)
    sort(v[i].begin(), v[i].end());

  int cnt[26] = {};

  while(k--)
    {
      char c;
      cin >> c;
      cout << v[c - 'a'][cnt[c - 'a'] % v[c - 'a'].size()] << endl;
      cnt[c - 'a']++;
    }
  
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 148 ms 6420 KB Output is correct
8 Correct 161 ms 6288 KB Output is correct
9 Correct 157 ms 6224 KB Output is correct
10 Correct 149 ms 6228 KB Output is correct