제출 #235115

#제출 시각아이디문제언어결과실행 시간메모리
235115VimmerZigZag (COCI17_zigzag)C++14
80 / 80
156 ms12408 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 100001 #define M ll(1e9 + 7) #define inf 1e9 + 1e9 using namespace std; typedef long double ld; typedef long long ll; typedef short int si; set <pair <int, string> > se[27]; int main() { // freopen("input4.txt", "r", stdin); freopen("output4.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { string s; cin >> s; se[s[0] - 'a'].insert({0, s}); } for (; m > 0; m--) { char c; cin >> c; int t = c - 'a'; pair <int, string> pt = *se[t].begin(); se[t].erase(se[t].begin()); cout << pt.S << '\n'; se[t].insert({pt.F + 1, pt.S}); } }
#Verdict Execution timeMemoryGrader output
Fetching results...