답안 #166653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166653 2019-12-03T11:47:20 Z Abdulaziz_Kazim ZigZag (COCI17_zigzag) C++17
80 / 80
449 ms 8080 KB
#include<bits/stdc++.h>
using namespace std;

vector<string>dizi[30];
long long int cnt[100007];
int main()
{
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	int n,k;
	cin >> k >> n;
	string a;
	for(int i=0;i<k;i++)
	{
		cin >> a;

		dizi[a[0]-'a'].push_back(a);
	}
	for(int i=0;i<30;i++)
	{
		sort(dizi[i].begin(),dizi[i].end());
	}
	char as;
	for(int i=0;i<n;i++)
	{
		cin >> as;
		int diz=cnt[as-'a']%(dizi[as-'a'].size());
		cout << dizi[as-'a'][diz]<<endl;
		cnt[as-'a']++;
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 448 ms 8056 KB Output is correct
8 Correct 442 ms 8056 KB Output is correct
9 Correct 449 ms 8080 KB Output is correct
10 Correct 444 ms 7984 KB Output is correct