# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493895 | 2021-12-13T10:02:19 Z | Karabasan | ZigZag (COCI17_zigzag) | C++17 | 58 ms | 8344 KB |
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,avx") #pragma GCC optimize("unroll-loops") int n,a,b,k; string s[100005]; char dizi[100005]; pair<int,int> ptr[30]; void solve() { memset(ptr,-1,sizeof ptr); cin>>n>>k; for(int i=0;i<n;i++) cin>>s[i]; for(int i=0;i<k;i++) cin>>dizi[i]; sort(s,s+n); for(int i=0;i<n;i++) { if(ptr[s[i][0]-'a'].first==-1) ptr[s[i][0]-'a']={i,i}; } for(int i=0;i<k;i++) { if(s[ptr[dizi[i]-'a'].second][0]!=dizi[i]) ptr[dizi[i]-'a'].second=ptr[dizi[i]-'a'].first; cout<<s[ptr[dizi[i]-'a'].second]<<endl; ptr[dizi[i]-'a'].second++; } } signed main() { fast1 //freopen ("lca.gir","r",stdin); //freopen ("lca.cik","w",stdout); int t=1; //cin>>t; while(t--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 2 ms | 3404 KB | Output is correct |
4 | Correct | 3 ms | 3456 KB | Output is correct |
5 | Correct | 2 ms | 3404 KB | Output is correct |
6 | Correct | 2 ms | 3472 KB | Output is correct |
7 | Correct | 58 ms | 8296 KB | Output is correct |
8 | Correct | 50 ms | 8300 KB | Output is correct |
9 | Correct | 48 ms | 8332 KB | Output is correct |
10 | Correct | 49 ms | 8344 KB | Output is correct |