답안 #473626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473626 2021-09-15T18:14:27 Z MamdouhN ZigZag (COCI17_zigzag) C++17
80 / 80
290 ms 7960 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

map<char,vector<string>>idk;
map<char,int>lol;
set<char>diff;

main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        diff.insert(s[0]);
        idk[s[0]].push_back(s);
    }
    for(auto v:diff)sort(idk[v].begin(),idk[v].end());
    while(q--)
    {
        char c;
        cin>>c;
        cout<<idk[c][lol[c]]<<endl;
        lol[c]++;
        if(lol[c]==idk[c].size())lol[c]=0;
    }
}

Compilation message

zigzag.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~
zigzag.cpp: In function 'int main()':
zigzag.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::map<char, long long int>::mapped_type' {aka 'long long int'} and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if(lol[c]==idk[c].size())lol[c]=0;
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 275 ms 7884 KB Output is correct
8 Correct 267 ms 7904 KB Output is correct
9 Correct 275 ms 7960 KB Output is correct
10 Correct 290 ms 7864 KB Output is correct