結果
問題 | No.893 お客様を誘導せよ |
ユーザー |
![]() |
提出日時 | 2024-10-03 01:00:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 2,917 ms |
コンパイル使用メモリ | 250,436 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 01:00:38 |
合計ジャッジ時間 | 4,340 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector<queue<int>> a(n); rep(i, n) { int p; cin >> p; rep(_, p) { int x; cin >> x; a[i].push(x); } } queue<int> ans; queue<int> q; rep(i, n) if (!a[i].empty()) q.push(i); while (!q.empty()) { int idx = q.front(); q.pop(); int x = a[idx].front(); a[idx].pop(); ans.push(x); if (!a[idx].empty()) q.push(idx); } while (!ans.empty()) { cout << ans.front() << ' '; ans.pop(); } cout << endl; return 0; }