結果
| 問題 |
No.1373 Directed Operations
|
| コンテスト | |
| ユーザー |
sbite
|
| 提出日時 | 2021-02-05 22:15:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 422 ms / 2,000 ms |
| コード長 | 1,435 bytes |
| コンパイル時間 | 3,136 ms |
| コンパイル使用メモリ | 213,360 KB |
| 最終ジャッジ日時 | 2025-01-18 12:32:06 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
int main()
{
int n;
cin >> n;
map<int, int> mp;
VI a(n);
rep(i, n - 1)
{
cin >> a[i];
mp[a[i]]++;
}
map<int, deque<int>> op;
deque<pair<int, int>> que;
rep(i, 1, n)
{
que.push_back({i, mp[i]});
while (que.front().second == 0 && !que.empty())
{
que.pop_front();
}
if (que.empty())
{
cout << "NO" << endl;
return 0;
}
op[que.front().first].push_back(i);
que.front().second--;
while (que.front().second == 0 && !que.empty())
{
que.pop_front();
}
}
cout << "YES" << endl;
rep(i, n - 1)
{
cout << op[a[i]].front() - a[i] + 1 << endl;
op[a[i]].pop_front();
}
}
sbite