Submission #79951

#TimeUsernameProblemLanguageResultExecution timeMemory
79951luckyboyZigZag (COCI17_zigzag)C++14
80 / 80
102 ms13312 KiB
/** Lucky Boy **/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pb push_back #define mp make_pair #define F first #define S second #define maxc 1000000007 #define maxn 1000006 #define maxm 500005 #define pii pair <int,int> #define Task "" using namespace std; int n,m,top[26]; vector <string> s[26]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //freopen(".inp", "r",stdin); cin >> n >> m; FOR(i,1,n) { string temp; cin >> temp; s[temp[0]-'a'].pb(temp); } FOR(i,0,25) sort(s[i].begin(),s[i].end()); while (m--) { char c; int w; cin >> c; w = c - 'a'; cout << s[w][top[w]++] << '\n'; if (top[w] == s[w].size()) top[w] = 0; } }

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:36:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (top[w] == s[w].size()) top[w] = 0;
             ~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...