Submission #43860

# Submission time Handle Problem Language Result Execution time Memory
43860 2018-03-25T17:50:16 Z heon ZigZag (COCI17_zigzag) C++11
48 / 80
2000 ms 12580 KB
#include<bits/stdc++.h>

using namespace std;

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

int main(){
	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());
	}
	for(int i = 0; i < m; i++){
		char slovo;
		cin >> slovo;
		string output = v[slovo - 'a'][0];
		cout << output << endl;
		v[slovo - 'a'].erase(v[slovo - 'a'].begin());
		v[slovo - 'a'].push_back(output);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 592 KB Output is correct
4 Correct 3 ms 704 KB Output is correct
5 Correct 3 ms 704 KB Output is correct
6 Correct 3 ms 728 KB Output is correct
7 Execution timed out 2021 ms 7800 KB Time limit exceeded
8 Execution timed out 2029 ms 9488 KB Time limit exceeded
9 Execution timed out 2045 ms 10944 KB Time limit exceeded
10 Execution timed out 2043 ms 12580 KB Time limit exceeded