Submission #197346

#TimeUsernameProblemLanguageResultExecution timeMemory
197346NeklixxZigZag (COCI17_zigzag)C++14
80 / 80
428 ms18060 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second #define all(v) v.begin(), v.end() #define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0); #define FILE freopen("test.in", "r", stdin); #define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";} #define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;} #define debug cout << "-----------------------------------------------" << endl; #define print1(a) cout << "{ " << a << " }" << endl; #define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl; #define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl; #define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl; using namespace std; //#define int long long const int INF = 1e9 + 228; const int MAXN = 1e5 + 228; set<pair<int, int>> s[MAXN]; signed main() { #ifdef LOCAL FILE; #endif sh; int n, q; cin >> n >> q; vector<pair<string, int>> v; for (int i = 0; i < n; i++) { string ss; cin >> ss; v.pb({ss, i}); } sort(all(v)); for (int i = 0; i < n; i++) { s[v[i].F[0]].insert({0, i}); } //cin >> q; for (int i = 0; i < q; i++) { char aa; cin >> aa; auto to = *s[aa].begin(); s[aa].erase(to); s[aa].insert({to.F + 1, to.S}); cout << v[to.S].F << endl; } return 0; }

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:39:14: warning: array subscript has type 'char' [-Wchar-subscripts]
   s[v[i].F[0]].insert({0, i});
              ^
zigzag.cpp:45:18: warning: array subscript has type 'char' [-Wchar-subscripts]
   auto to = *s[aa].begin();
                  ^
zigzag.cpp:46:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   s[aa].erase(to);
       ^
zigzag.cpp:47:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   s[aa].insert({to.F + 1, to.S});
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...