답안 #43862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43862 2018-03-25T18:01:00 Z heon ZigZag (COCI17_zigzag) C++11
80 / 80
218 ms 6612 KB
#include<bits/stdc++.h>

using namespace std;

int n,m;
vector <string> v[26];
int counter[26];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		string input;
		cin >> input;
		v[input[0] - 'a'].push_back(input);
	}
	for(int i = 0; i < 26; i++){
		sort(v[i].begin(), v[i].end());
		counter[i] = 0;
	}
	for(int i = 0; i < m; i++){
		char slovo;
		cin >> slovo;
		cout << v[slovo - 'a'][counter[slovo - 'a'] % v[slovo - 'a'].size()] << endl;
		counter[slovo - 'a']++;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 440 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 206 ms 6508 KB Output is correct
8 Correct 211 ms 6608 KB Output is correct
9 Correct 218 ms 6612 KB Output is correct
10 Correct 203 ms 6612 KB Output is correct