結果

問題 No.893 お客様を誘導せよ
ユーザー kunitaka4649kunitaka4649
提出日時 2019-09-28 00:39:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,483 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 76,148 KB
実行使用メモリ 4,540 KB
最終ジャッジ日時 2023-10-25 08:35:34
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 21 ms
4,348 KB
testcase_04 AC 21 ms
4,348 KB
testcase_05 AC 20 ms
4,348 KB
testcase_06 AC 14 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 42 ms
4,540 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 1001;

int main(int argc, const char * argv[]) {
    // input from txt
    /////////
    //write//
    /////////
    
    int n;
    queue<int> q[MAX];
    cin >> n;
    rep(i, n){
        int p;
        cin >> p;
        rep(j, p){
            int a;
            cin >> a;
            q[i].push(a);
        }
    }
    
    bool ok = true;
    queue<int> res;
    while(ok){
        ok = false;
        rep(i, n)
        {
            if(!q[i].empty())
            {
                int f = q[i].front();
                q[i].pop();
                res.push(f);
                ok = true;
                
            }
        }
    }
    
    int v = res.size();
    rep(i,v){
        if(i)cout << " ";
        cout << res.front();
        res.pop();
    }
    
    cout << endl;
    
    
    return 0;
}
0