Submission #546895

#TimeUsernameProblemLanguageResultExecution timeMemory
546895AbdelmagedNourZigZag (COCI17_zigzag)C++17
80 / 80
51 ms7936 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q; cin>>n>>q; int ptr[26]={}; vector<vector<string>>v(26); for(int i=0;i<n;i++){ string s; cin>>s; v[s[0]-'a'].push_back(s); } for(int i=0;i<26;i++)sort(v[i].begin(),v[i].end()); for(int i=0;i<q;i++){ char c; cin>>c; cout<<v[c-'a'][ptr[c-'a']++]<<"\n"; if(ptr[c-'a']>=v[c-'a'].size())ptr[c-'a']=0; } return 0; }

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if(ptr[c-'a']>=v[c-'a'].size())ptr[c-'a']=0;
      |            ~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...