結果

問題 No.893 お客様を誘導せよ
ユーザー 👑 jupirojupiro
提出日時 2020-01-27 03:25:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 90,568 KB
実行使用メモリ 5,388 KB
最終ジャッジ日時 2023-10-12 12:42:18
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 19 ms
4,480 KB
testcase_04 AC 19 ms
4,540 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 13 ms
4,356 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 39 ms
5,388 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 510000;
const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;

using namespace std;
typedef unsigned long long ull;
typedef  long long ll;


int main()
{
	ll N;
	cin >> N;
	vector<queue<ll>> vq(N);
	for (ll i = 0; i < N; i++) {
		ll p;
		cin >> p;
		for (ll j = 0; j < p; j++) {
			ll a;
			cin >> a;
			vq[i].push(a);
		}
	}
	vector<ll> res;
	while (1) {
		bool flag = false;
		for (ll i = 0; i < N; i++) {
			if (!vq[i].empty()) {
				res.push_back(vq[i].front());
				flag = true;
				vq[i].pop();
			}
		}
		if (!flag) {
			break;
		}
	}

	for (ll i = 0; i < res.size(); i++) {
		cout << res[i];
		if (i == (ll)res.size() - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return 0;
}
0