# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546895 | 2022-04-08T19:41:29 Z | AbdelmagedNour | ZigZag (COCI17_zigzag) | C++17 | 51 ms | 7936 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q; cin>>n>>q; int ptr[26]={}; vector<vector<string>>v(26); for(int i=0;i<n;i++){ string s; cin>>s; v[s[0]-'a'].push_back(s); } for(int i=0;i<26;i++)sort(v[i].begin(),v[i].end()); for(int i=0;i<q;i++){ char c; cin>>c; cout<<v[c-'a'][ptr[c-'a']++]<<"\n"; if(ptr[c-'a']>=v[c-'a'].size())ptr[c-'a']=0; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 328 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 328 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 47 ms | 7936 KB | Output is correct |
8 | Correct | 51 ms | 7884 KB | Output is correct |
9 | Correct | 47 ms | 7900 KB | Output is correct |
10 | Correct | 46 ms | 7884 KB | Output is correct |