제출 #473127

#제출 시각아이디문제언어결과실행 시간메모리
473127MamdouhNZigZag (COCI17_zigzag)C++17
48 / 80
2083 ms13728 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" vector<string>words; map<string,int>done; bool comp(string a,string b) { if(a[0]!=b[0])return a<b; if(done[a]==done[b])return a<b; return done[a]<done[b]; } string bs(char c) { int st=0,en=words.size(); int mid; while(st<en) { mid=(st+en)/2; if(words[mid][0]>c)en = mid-1; if(words[mid][0]<c)st = mid+1; if(words[mid][0]==c)en =mid; } mid=(st+en)/2; done[words[mid]]++; return words[mid]; } main() { int n,q; cin>>n>>q; for(int i=0;i<n;i++) { string x; cin>>x; words.push_back(x); } while(q--) { sort(words.begin(),words.end(),comp); char c; cin>>c; cout<<bs(c)<<endl;; } }

컴파일 시 표준 에러 (stderr) 메시지

zigzag.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...