답안 #37976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37976 2017-12-29T19:30:14 Z tmk ZigZag (COCI17_zigzag) C++14
64 / 80
226 ms 6720 KB
#include<bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
typedef long long LL;

vector<string>tab[26];
int pt[26];


int main()
{
	ios_base::sync_with_stdio(0);
	
	int k,n;
	cin>>k>>n;
	for(int i=0;i<k;i++)
	{
		string t;
		cin>>t;
		tab[(int)t[0]-'a'].pb(t);
	}
	for(int i=0;i<26;i++)
		sort(tab[i].begin(),tab[i].end());
	for(int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		int kt=(int)c-'a';
		cout<<tab[kt][pt[kt]]<<"\n";
		if(++pt[kt]==(int)tab[kt].size())
			pt[kt]=0;
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
4 Correct 3 ms 2180 KB Output is correct
5 Correct 3 ms 2180 KB Output is correct
6 Correct 3 ms 2180 KB Output is correct
7 Correct 163 ms 6720 KB Output is correct
8 Correct 226 ms 6720 KB Output is correct
9 Runtime error 186 ms 6720 KB Execution timed out (wall clock limit exceeded)
10 Runtime error 159 ms 6720 KB Execution timed out (wall clock limit exceeded)