結果
問題 | No.1014 competitive fighting |
ユーザー |
![]() |
提出日時 | 2020-03-21 13:57:10 |
言語 | C++17 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 136 ms / 2,000 ms |
コード長 | 3,408 Byte |
コンパイル時間 | 3,898 ms |
使用メモリ | 46,248 KB |
最終ジャッジ日時 | 2022-10-30 21:13:01 |
合計ジャッジ時間 | 10,064 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
7,764 KB |
testcase_01 | AC | 5 ms
7,520 KB |
testcase_02 | AC | 5 ms
7,680 KB |
testcase_03 | AC | 5 ms
7,640 KB |
testcase_04 | AC | 5 ms
7,708 KB |
testcase_05 | AC | 126 ms
27,460 KB |
testcase_06 | AC | 126 ms
27,532 KB |
testcase_07 | AC | 126 ms
27,532 KB |
testcase_08 | AC | 126 ms
27,536 KB |
testcase_09 | AC | 126 ms
27,456 KB |
testcase_10 | AC | 136 ms
46,248 KB |
testcase_11 | AC | 76 ms
19,924 KB |
testcase_12 | AC | 127 ms
27,504 KB |
testcase_13 | AC | 60 ms
17,076 KB |
testcase_14 | AC | 56 ms
16,672 KB |
testcase_15 | AC | 66 ms
17,408 KB |
testcase_16 | AC | 7 ms
7,984 KB |
testcase_17 | AC | 27 ms
11,436 KB |
testcase_18 | AC | 107 ms
25,688 KB |
testcase_19 | AC | 124 ms
27,192 KB |
testcase_20 | AC | 47 ms
15,596 KB |
testcase_21 | AC | 98 ms
24,820 KB |
testcase_22 | AC | 73 ms
18,460 KB |
testcase_23 | AC | 31 ms
12,328 KB |
testcase_24 | AC | 32 ms
12,224 KB |
testcase_25 | AC | 11 ms
8,672 KB |
testcase_26 | AC | 97 ms
24,564 KB |
testcase_27 | AC | 26 ms
11,492 KB |
testcase_28 | AC | 28 ms
11,620 KB |
testcase_29 | AC | 5 ms
7,864 KB |
testcase_30 | AC | 122 ms
27,292 KB |
testcase_31 | AC | 100 ms
25,076 KB |
testcase_32 | AC | 5 ms
7,800 KB |
testcase_33 | AC | 9 ms
8,300 KB |
testcase_34 | AC | 64 ms
19,464 KB |
testcase_35 | AC | 77 ms
19,988 KB |
testcase_36 | AC | 60 ms
19,008 KB |
testcase_37 | AC | 6 ms
8,032 KB |
testcase_38 | AC | 47 ms
13,752 KB |
testcase_39 | AC | 26 ms
10,556 KB |
testcase_40 | AC | 45 ms
13,752 KB |
testcase_41 | AC | 36 ms
13,376 KB |
testcase_42 | AC | 74 ms
19,540 KB |
testcase_43 | AC | 9 ms
8,168 KB |
testcase_44 | AC | 70 ms
19,728 KB |
testcase_45 | AC | 41 ms
13,716 KB |
testcase_46 | AC | 12 ms
8,928 KB |
testcase_47 | AC | 24 ms
10,552 KB |
testcase_48 | AC | 62 ms
19,124 KB |
testcase_49 | AC | 7 ms
7,900 KB |
testcase_50 | AC | 73 ms
19,544 KB |
testcase_51 | AC | 42 ms
13,640 KB |
testcase_52 | AC | 7 ms
7,904 KB |
testcase_53 | AC | 125 ms
27,676 KB |
ソースコード
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i @hamayanhamayan0 / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ struct DirectedGraphRangeEdge { int NV; vector<vector<int>> E; void init(int n) { NV = 1; while (NV < n) NV *= 2; E.resize(NV * 2); rep(i, 1, NV) { E[i].push_back(i * 2); E[i].push_back(i * 2 + 1); } } // [x, y) void add(int from, int x, int y) { add(from + NV, x, y, 0, NV, 1); } void add(int from, int x, int y, int l, int r, int k) { if (r <= x || y <= l) return; if (x <= l && r <= y) { E[from].push_back(k); return; } add(from, x, y, l, (l + r) / 2, k * 2); add(from, x, y, (l + r) / 2, r, k * 2 + 1); } }; int N; DirectedGraphRangeEdge dgre; vector<tuple<int, int, int, int>> ABCi; ll ans[101010]; //--------------------------------------------------------------------------------------------------- ll memo[1 << 19]; // -1: not visited -2: pending 0<=: cached infl: BAN ll dfs(int cu) { if (0 <= memo[cu]) return memo[cu]; if (memo[cu] == -2) return memo[cu] = infl; memo[cu] = -2; ll res = 0; fore(to, dgre.E[cu]) chmax(res, dfs(to)); if (res == infl) return infl; if (dgre.NV <= cu) res += get<1>(ABCi[cu - dgre.NV]); return memo[cu] = res; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; dgre.init(N); rep(i, 0, N) { int a, b, c; cin >> a >> b >> c; ABCi.push_back(make_tuple(a, b, c, i)); } sort(all(ABCi)); rep(i, 0, N) { int b, c, _; tie(_, b, c, _) = ABCi[i]; int idx = lower_bound(all(ABCi), make_tuple(b - c + 1, -1, -1, -1)) - ABCi.begin(); if (i < idx) { if (0 < i) dgre.add(i, 0, i); if (i + 1 < idx) dgre.add(i, i + 1, idx); } else dgre.add(i, 0, idx); } rep(i, 0, 1 << 19) memo[i] = -1; rep(i, 0, N) ans[get<3>(ABCi[i])] = dfs(i + dgre.NV); rep(i, 0, N) { if (ans[i] == infl) printf("BAN\n"); else printf("%lld\n", ans[i]); } }