답안 #447308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447308 2021-07-26T03:40:07 Z dvtd ZigZag (COCI17_zigzag) C++14
0 / 80
88 ms 9668 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

vector<string> _list[50];
int idx[50];
int n, m;

int main()
{

    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        string tmp; cin >> tmp;
        idx[tmp[0] - 'a'] = 0;
        _list[tmp[0] - 'a'].push_back(tmp);
    }

    for (int i = 0; i <= 27; ++i)
        sort(_list[i].begin(),_list[i].end());

    for (int i = 0; i < m; ++i)
    {
        char tmp; cin >> tmp;
        cout << _list[tmp - 'a'][idx[tmp]] << endl;
        idx[tmp] =(idx[tmp] + 1) % (int)(_list[tmp - 'a'].size());
    }
}

Compilation message

zigzag.cpp: In function 'int main()':
zigzag.cpp:27:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   27 |         cout << _list[tmp - 'a'][idx[tmp]] << endl;
      |                                      ^~~
zigzag.cpp:28:13: warning: array subscript has type 'char' [-Wchar-subscripts]
   28 |         idx[tmp] =(idx[tmp] + 1) % (int)(_list[tmp - 'a'].size());
      |             ^~~
zigzag.cpp:28:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   28 |         idx[tmp] =(idx[tmp] + 1) % (int)(_list[tmp - 'a'].size());
      |                        ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 292 KB Execution killed with signal 11
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Runtime error 1 ms 460 KB Execution killed with signal 11
4 Runtime error 2 ms 460 KB Execution killed with signal 11
5 Runtime error 1 ms 460 KB Execution killed with signal 11
6 Runtime error 2 ms 460 KB Execution killed with signal 11
7 Runtime error 84 ms 9668 KB Execution killed with signal 11
8 Runtime error 83 ms 9552 KB Execution killed with signal 11
9 Runtime error 88 ms 9668 KB Execution killed with signal 11
10 Runtime error 84 ms 9596 KB Execution killed with signal 11