結果
問題 | No.2160 みたりのDominator |
ユーザー | Kude |
提出日時 | 2022-12-11 16:17:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,657 bytes |
コンパイル時間 | 3,174 ms |
コンパイル使用メモリ | 252,172 KB |
実行使用メモリ | 20,596 KB |
最終ジャッジ日時 | 2024-10-15 13:14:02 |
合計ジャッジ時間 | 11,970 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 7 ms
7,936 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 13 ms
17,280 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 47 ms
10,532 KB |
testcase_41 | AC | 37 ms
9,728 KB |
testcase_42 | AC | 24 ms
7,296 KB |
testcase_43 | AC | 36 ms
8,948 KB |
testcase_44 | AC | 46 ms
10,280 KB |
testcase_45 | AC | 46 ms
10,356 KB |
testcase_46 | AC | 36 ms
9,728 KB |
testcase_47 | AC | 23 ms
7,168 KB |
testcase_48 | AC | 35 ms
8,832 KB |
testcase_49 | AC | 44 ms
10,112 KB |
testcase_50 | AC | 39 ms
9,984 KB |
testcase_51 | AC | 26 ms
7,808 KB |
testcase_52 | AC | 37 ms
9,472 KB |
testcase_53 | AC | 47 ms
10,240 KB |
testcase_54 | AC | 27 ms
7,296 KB |
testcase_55 | AC | 311 ms
17,732 KB |
testcase_56 | AC | 298 ms
18,644 KB |
testcase_57 | AC | 328 ms
18,764 KB |
testcase_58 | AC | 314 ms
17,448 KB |
testcase_59 | AC | 324 ms
17,436 KB |
testcase_60 | AC | 259 ms
20,596 KB |
testcase_61 | WA | - |
testcase_62 | AC | 279 ms
17,048 KB |
testcase_63 | AC | 335 ms
19,460 KB |
testcase_64 | AC | 246 ms
18,656 KB |
testcase_65 | AC | 79 ms
11,904 KB |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 208 ms
15,432 KB |
testcase_69 | AC | 192 ms
16,464 KB |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | AC | 45 ms
5,316 KB |
testcase_73 | AC | 265 ms
16,364 KB |
testcase_74 | AC | 254 ms
16,400 KB |
testcase_75 | AC | 6 ms
7,424 KB |
testcase_76 | AC | 4 ms
5,760 KB |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
61_evil_bias_nocross_01.txt | AC | 45 ms
11,136 KB |
61_evil_bias_nocross_02.txt | AC | 33 ms
9,496 KB |
61_evil_bias_nocross_03.txt | AC | 21 ms
7,808 KB |
61_evil_bias_nocross_04.txt | AC | 23 ms
7,692 KB |
61_evil_bias_nocross_05.txt | AC | 46 ms
11,108 KB |
61_evil_bias_nocross_06.txt | AC | 38 ms
9,776 KB |
61_evil_bias_nocross_07.txt | AC | 25 ms
8,192 KB |
61_evil_bias_nocross_08.txt | AC | 33 ms
9,120 KB |
61_evil_bias_nocross_09.txt | AC | 44 ms
10,976 KB |
61_evil_bias_nocross_10.txt | AC | 16 ms
6,560 KB |
61_evil_bias_nocross_11.txt | AC | 30 ms
8,960 KB |
61_evil_bias_nocross_12.txt | AC | 38 ms
9,288 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic pop using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; struct S { int il, jl, ir, jr; friend ostream& operator<<(ostream& os, const S& r) { return os << "(" << r.il << ", " << r.jl << ", " << r.ir << ", " << r.jr << ")"; } }; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n1, n2, n3, m; cin >> n1 >> n2 >> n3 >> m; bool ok = true; vector<P> e11, e22, e33, e12, e13, e23; rep(_, m) { int u, v; cin >> u >> v; if (u > v) swap(u, v); if (v <= n1) { e11.emplace_back(u, v); } else if (v <= n1 + n2) { if (u <= n1) e12.emplace_back(u, v - n1); else e22.emplace_back(u - n1, v - n1); } else if (v <= n1 + n2 + n3) { if (u <= n1) e13.emplace_back(u, v - (n1 + n2)); else if (u <= n1 + n2) e23.emplace_back(u - n1, v - (n1 + n2)); else e33.emplace_back(u - (n1 + n2), v - (n1 + n2)); } else if (v == n1 + n2 + n3 + 1) { if (u <= n1) e11.emplace_back(0, u); else if (u <= n1 + n2) e22.emplace_back(0, u - n1); else e33.emplace_back(0, u - (n1 + n2)); } else { if (u <= n1) e11.emplace_back(u, n1 + 1); else if (u <= n1 + n2) e22.emplace_back(u - n1, n2 + 1); else if (u <= n1 + n2 + n3) e33.emplace_back(u - (n1 + n2), n3 + 1); else ok = false; } } if (!ok) { cout << 0 << '\n'; return 0; } n1++, n2++, n3++; sort(all(e12)); vector<S> st{{0, 0, -1, -1}}; for(auto [i, j]: e12) { if (i == st.back().il) { st.back().jl = j; } else if (j <= st.back().jl) { S r = st.back(); st.pop_back(); r.il = i; while(!st.empty() && st.back().jl >= j) st.pop_back(); if (!st.empty()) chmin(st.back().jr, j); st.emplace_back(r); } else { st.back().ir = i; st.back().jr = j; st.push_back(S{i, j, -1, -1}); } } st.back().ir = n1; st.back().jr = n2; constexpr int INF = 1001001001; rep(_, 2) { int bad_l = INF, bad_r = -INF; for(auto [l, r]: e11) chmin(bad_l, l), chmax(bad_r, r); vector<S> nst; for(S r: st) { if (r.il < bad_l) { chmin(r.ir, bad_l); } else if (r.ir <= bad_r) { continue; } else { chmax(r.il, bad_r); } nst.emplace_back(r); } for(auto& [il, jl, ir, jr]: st) swap(il, jl), swap(ir, jr); swap(e11, e22); } int sz = st.size(); VL acc(sz + 1); rep(i, sz) { auto [il, jl, ir, jr] = st[i]; acc[i+1] = acc[i] + ll(ir - il) * (jr - jl); } multiset<int, greater<int>> imn{-INF}, jmn{-INF}; multiset<int> imx{INF}, jmx{INF}; VVI ev1(n3 + 1), ev2(n3 + 1); for(auto [i, k]: e13) { imx.insert(i); ev1[k].emplace_back(i); } for(auto [j, k]: e23) { jmx.insert(j); ev2[k].emplace_back(j); } int bad_l = INF, bad_r = -INF; for(auto [l, r]: e33) chmin(bad_l, l), chmax(bad_r, r); auto get_area = [](const S& r1, const S& r2) { int il = max(r1.il, r2.il); int jl = max(r1.jl, r2.jl); int ir = min(r1.ir, r2.ir); int jr = min(r1.jr, r2.jr); if (il >= ir || jl >= jr) return 0LL; return ll(ir - il) * (jr - jl); }; ll ans = 0; rep(z, n3) { for(int i: ev1[z]) imx.erase(imx.find(i)), imn.insert(i); for(int j: ev2[z]) jmx.erase(jmx.find(j)), jmn.insert(j); if (bad_l <= z && z < bad_r) continue; S r{*imn.begin(), *jmn.begin(), *imx.begin(), *jmx.begin()}; int from = max(lower_bound(all(st), r, [](const S& x, const S& y) { return x.il < y.il; }) - st.begin(), lower_bound(all(st), r, [](const S& x, const S& y) { return x.jl < y.jl; }) - st.begin()); int to = min(upper_bound(all(st), r, [](const S& x, const S& y) { return x.ir < y.ir; }) - st.begin(), upper_bound(all(st), r, [](const S& x, const S& y) { return x.jr < y.jr; }) - st.begin()); if (from < to) ans += acc[to] - acc[from]; if (from) ans += get_area(st[from - 1], r); if (to < sz && to != from - 1) ans += get_area(st[to], r); } cout << ans << '\n'; }