답안 #235120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235120 2020-05-27T06:33:21 Z NONAME ZigZag (COCI17_zigzag) C++17
80 / 80
343 ms 6520 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define el '\n'
#define pb push_back
using namespace std;

int n, q, p[26];
vector <string> v[26];

int main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		v[s[0] - 'a'].pb(s);
	}
	
	for (int i = 0; i < 26; i++)
		sort(v[i].begin(), v[i].end()), p[i] = 0;
	
	while (q--) {
		char c;
		cin >> c;
		cout << v[c - 'a'][(p[c - 'a']++) % sz(v[c - 'a'])] << el;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 343 ms 6392 KB Output is correct
8 Correct 327 ms 6520 KB Output is correct
9 Correct 334 ms 6520 KB Output is correct
10 Correct 326 ms 6392 KB Output is correct