結果

問題 No.893 お客様を誘導せよ
ユーザー Y17Y17
提出日時 2019-09-27 21:29:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 165,048 KB
実行使用メモリ 4,560 KB
最終ジャッジ日時 2023-10-25 01:49:00
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 7 ms
4,372 KB
testcase_03 AC 20 ms
4,372 KB
testcase_04 AC 21 ms
4,372 KB
testcase_05 AC 18 ms
4,372 KB
testcase_06 AC 13 ms
4,372 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 41 ms
4,560 KB
testcase_09 AC 3 ms
4,360 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 3 ms
4,356 KB
testcase_12 AC 2 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    queue<int> que[1010];

    queue<int> num;

    for(int i = 0;i < n;i++){
        int p;
        cin >> p;
        for(int j = 0;j < p;j++){
            int a;
            cin >> a;
            que[i].push(a);
        }
        num.push(i);
    }

    queue<int> ans;

    while(!num.empty()){
        int idx = num.front();
        num.pop();
        if(que[idx].size() == 0) continue;

        ans.push(que[idx].front());
        que[idx].pop();
        num.push(idx);
    }

    while(!ans.empty()){
        cout << ans.front();
        ans.pop();
        if(ans.empty()){
            cout << endl;
        }else{
            cout << " ";
        }
    }

    return 0;
}


0