Submission #447298

#TimeUsernameProblemLanguageResultExecution timeMemory
4472982548631ZigZag (COCI17_zigzag)C++17
80 / 80
176 ms12608 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vii; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vii> vvii; #define fastIO ios::sync_with_stdio(false), cin.tie(NULL) #define forw(i, l, r) for( int i = (l) ; i < (r) ; i++ ) #define forb(i, r, l) for( int i = (r) ; i >= (l) ; i-- ) #define log2i(x) (64 - __builtin_clzll(1ll * (x)) - 1) #define numBit(x) (__builtin_popcountll(1ll * (x))) #define getBit(x, i) ((x) >> (i) & 1) #define Pi acos(-1.0l) #define sz(x) int(x.size()) #define mt make_tuple #define mp make_pair #define fi first #define se second #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(x) cerr << #x << " = " << x << '\n'; const int N = 1e5 + 7; int n, q; set<pair<int, pair<string, int> > > d[26]; int main() { fastIO; #ifndef ONLINE_JUDGE //freopen("test.inp","r",stdin); //freopen("test.out","w",stdout); #endif cin >> n >> q; forw(i, 0, n) { string st; cin >> st; d[st[0] - 'a'].insert(mp(0, mp(st, i))); } while(q--) { char c; cin >> c; auto tmp = *d[c - 'a'].begin(); d[c - 'a'].erase(d[c - 'a'].begin()); cout << tmp.se.fi << '\n'; tmp.fi++; d[c - 'a'].insert(tmp); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...