結果
問題 | No.1373 Directed Operations |
ユーザー | wdiiahk |
提出日時 | 2021-02-06 15:54:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 6,758 bytes |
コンパイル時間 | 2,836 ms |
コンパイル使用メモリ | 219,740 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 01:17:42 |
合計ジャッジ時間 | 5,140 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 134 ms
6,944 KB |
testcase_03 | AC | 10 ms
6,940 KB |
testcase_04 | AC | 13 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 133 ms
6,940 KB |
testcase_07 | AC | 5 ms
6,940 KB |
testcase_08 | AC | 16 ms
6,944 KB |
testcase_09 | AC | 20 ms
6,944 KB |
testcase_10 | AC | 17 ms
6,940 KB |
testcase_11 | AC | 5 ms
6,940 KB |
testcase_12 | AC | 17 ms
6,944 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 145 ms
6,944 KB |
testcase_15 | AC | 130 ms
6,944 KB |
testcase_16 | AC | 148 ms
6,944 KB |
testcase_17 | AC | 94 ms
6,944 KB |
testcase_18 | AC | 57 ms
6,944 KB |
testcase_19 | AC | 55 ms
6,940 KB |
testcase_20 | AC | 73 ms
6,940 KB |
ソースコード
//デバッグ用オプション:-fsanitize=undefined,address //コンパイラ最適化 #pragma GCC optimize("Ofast") //インクルードなど #include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; namespace { typedef long long ll; using vint = vector<int>; using vll = vector<ll>; using vbool = vector<bool>; using vs = vector<string>; using P = pair<ll, ll>; using vp = vector<P>; template <class T> using arr = vector<vector<T>>; //マクロ #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < ll(b); i++) #define FORD(i, a, b) for (ll i = a; i >= ll(b); i--) #define FORA(i, I) for (const auto &i : I) #define ALL(x) x.begin(), x.end() #define SIZE(x) ll(x.size()) #define INF 100000000000000 template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } template <class T> void pl(T x) { cout << x << " "; } template <class T> void pr(T x) { cout << x << endl; } template <class T> void prvec(const vector<T> &a) { REP(i, a.size() - 1) { cout << a[i] << " "; } pr(a[a.size() - 1]); } template <class T> void prarr(const arr<T> &a) { REP(i, a.size()) if (a[i].empty()) pr(""); else prvec(a[i]); } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first + r.first, l.second + r.second}; } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first - r.first, l.second - r.second}; } template <typename T> pair<T, T> operator*(const pair<T, T> &l, const T &r) { return {l.first * r, l.second * r}; } template <typename T> pair<T, T> operator/(const pair<T, T> &l, const T &r) { return {l.first / r, l.second / r}; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &pa) { is >> pa.first >> pa.second; return is; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename... Ts> istream &operator>>(istream &is, tuple<Ts...> &theTuple) { apply([&is](Ts &...tupleArgs) { ((is >> tupleArgs), ...); }, theTuple); return is; } template <typename... Ts> ostream &operator<<(ostream &os, const tuple<Ts...> &theTuple) { apply([&os](const Ts &...tupleArgs) { os << '('; size_t n(0); ((os << tupleArgs << (++n < sizeof...(Ts) ? "," : "")), ...); os << ')'; }, theTuple); return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } // template <typename T> void for_enum(T &container, std::function<bool(int, typename T::value_type &)> op) { int idx = 0; for (auto &value : container) { if (!op(idx++, value)) { break; } } } template <typename S, typename T> map<S, T> group_by(T &container, std::function<S(typename T::value_type &)> op) { map<S, T> grouped; for (auto &value : container) { grouped[op(value)].push_back(value); } return grouped; } template <class Container, class Transform> Container fmap(const Container &c, Transform f) { Container r; r.reserve(c.size()); transform(ALL(c), back_inserter(r), f); return r; } template <class Container, class Predicate> Container ffilter(const Container &c, Predicate f) { Container r; std::copy_if(ALL(c), back_inserter(r), f); return r; } template <class Container, class InitialT, class BinaryOp> InitialT freduce(const Container &c, InitialT v, BinaryOp op) { return accumulate(ALL(c), v, op); } } // namespace // const P udlr[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; struct Constants { ll N; Constants() { cin >> N; } } C; struct Args { vll a; vll ids; Args() : a(C.N - 1), ids(C.N - 1, 0) { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> a; for_enum(ids, [](int i, ll &x) { x = i; return true; }); sort(ALL(ids), [&](ll l, ll r) { return a.at(l) < a.at(r); }); // sort(ALL(a)); } } args; struct Solver { bool bans; vll ans; Solver() : bans(true), ans(C.N - 1, 0) { } // void solve() { REP(i, C.N - 1) { ll id = args.ids.at(i); ll value = args.a.at(id); if (i + 1 < value) { bans = false; return; } else { ans.at(id) = (i + 1 - value) + 1; } } } // void output() { if (!bans) { pr("NO"); } else { pr("YES"); FORA(a, ans) pr(a); } } } s; int main() { s.solve(); s.output(); return 0; }