結果

問題 No.893 お客様を誘導せよ
ユーザー face4face4
提出日時 2019-09-27 21:25:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 76,352 KB
実行使用メモリ 4,660 KB
最終ジャッジ日時 2023-10-25 01:39:14
合計ジャッジ時間 1,456 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 7 ms
4,348 KB
testcase_03 AC 19 ms
4,432 KB
testcase_04 AC 19 ms
4,428 KB
testcase_05 AC 17 ms
4,380 KB
testcase_06 AC 12 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 39 ms
4,660 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,356 KB
testcase_12 AC 3 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    queue<int> q[n];
    for(int i = 0; i < n; i++){
        int p;  cin >> p;
        while(p-- > 0){
            int x;  cin >> x;
            q[i].push(x);
        }
    }
    queue<int> j;
    for(int i = 0; i < n; i++)  if(!q[i].empty())   j.push(i);
    vector<int> v;
    while(!j.empty()){
        int x = j.front();  j.pop();
        v.push_back(q[x].front());  q[x].pop();
        if(!q[x].empty())   j.push(x);
    }
    for(int i = 0; i < v.size(); i++)   cout << v[i] << " \n"[i+1==v.size()];
    return 0;
}
0