답안 #797080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797080 2023-07-29T06:10:54 Z Trisanu_Das ZigZag (COCI17_zigzag) C++17
80 / 80
161 ms 7880 KB
#include<bits/stdc++.h>
using namespace std;
 
vector<string>v[30];
long long cnt[100007];
int main()
{
	int n,k;
	cin>>k >>n;
	string a;
	for(int i=0;i<k;i++){
		cin>>a;
		v[a[0]-'a'].push_back(a);
	}
	for(int i=0;i<30;i++){
		sort(v[i].begin(),v[i].end());
	}
	char c;
	for(int i=0;i<n;i++)
	{
		cin>>c;
		int s=cnt[c-'a'] % (v[c-'a'].size());
		cout<<v[c-'a'][s]<<endl;
		cnt[c-'a']++;
	}
 return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 159 ms 7820 KB Output is correct
8 Correct 160 ms 7768 KB Output is correct
9 Correct 159 ms 7872 KB Output is correct
10 Correct 161 ms 7880 KB Output is correct