Submission #42283

#TimeUsernameProblemLanguageResultExecution timeMemory
42283milmillinZigZag (COCI17_zigzag)C++14
80 / 80
243 ms13872 KiB
#include <cstdio> #include <vector> #include <queue> #include <string> #include <iostream> using namespace std; struct word { string x; int cnt; }; bool operator< (const word &a, const word&b) { if (a.cnt!=b.cnt) return a.cnt>b.cnt; return a.x>b.x; } priority_queue<word> qq[30]; int main () { int k,n; scanf("%d%d",&k,&n); string x; for (int i=0;i<k;i++) { cin>>x; qq[x[0]-'a'].push(word{x,0}); } char xx; word now; for (int i=0;i<n;i++) { scanf(" %c",&xx); now = qq[xx-'a'].top(); qq[xx-'a'].pop(); cout << now.x << '\n'; now.cnt++; qq[xx-'a'].push(now); } return 0; }

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:23:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&k,&n);
                     ^
zigzag.cpp:32:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",&xx);
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...