結果
問題 | No.2160 みたりのDominator |
ユーザー | 👑 hos.lyric |
提出日時 | 2022-12-11 01:14:33 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 5,552 bytes |
コンパイル時間 | 1,200 ms |
コンパイル使用メモリ | 114,712 KB |
実行使用メモリ | 20,688 KB |
最終ジャッジ日時 | 2024-10-15 01:16:54 |
合計ジャッジ時間 | 13,108 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 13 ms
13,568 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | WA | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 1 ms
5,248 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | WA | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | WA | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | RE | - |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | WA | - |
testcase_62 | AC | 92 ms
18,980 KB |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | AC | 83 ms
18,680 KB |
testcase_69 | RE | - |
testcase_70 | AC | 81 ms
20,688 KB |
testcase_71 | RE | - |
testcase_72 | WA | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | WA | - |
testcase_83 | RE | - |
61_evil_bias_nocross_01.txt | WA | - |
61_evil_bias_nocross_02.txt | WA | - |
61_evil_bias_nocross_03.txt | AC | 14 ms
9,472 KB |
61_evil_bias_nocross_04.txt | WA | - |
61_evil_bias_nocross_05.txt | AC | 23 ms
13,328 KB |
61_evil_bias_nocross_06.txt | WA | - |
61_evil_bias_nocross_07.txt | WA | - |
61_evil_bias_nocross_08.txt | AC | 20 ms
12,672 KB |
61_evil_bias_nocross_09.txt | AC | 25 ms
13,076 KB |
61_evil_bias_nocross_10.txt | WA | - |
61_evil_bias_nocross_11.txt | AC | 16 ms
11,008 KB |
61_evil_bias_nocross_12.txt | WA | - |
ソースコード
#include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } int N[3], M; vector<int> U, V; int main() { for (; ~scanf("%d%d%d%d", &N[0], &N[1], &N[2], &M); ) { for (int h = 0; h < 3; ++h) { ++N[h]; } U.resize(M); V.resize(M); for (int m = 0; m < M; ++m) { scanf("%d%d", &U[m], &V[m]); if (U[m] > V[m]) { swap(U[m], V[m]); } } const int src = (N[0] - 1) + (N[1] - 1) + (N[2] - 1) + 1; const int snk = src + 1; const int offs[3] = {0, (N[0] - 1), (N[0] - 1) + (N[1] - 1)}; auto decode = [&](int h, int u) -> int { if (u == src) return 0; if (u == snk) return N[h]; u -= offs[h]; if (0 < u && u < N[h]) return u; return -1; }; vector<pair<int, int>> pss[3][3]; for (int m = 0; m < M; ++m) { for (int h0 = 0; h0 < 3; ++h0) for (int h1 = h0; h1 < 3; ++h1) { const int u = decode(h0, U[m]); const int v = decode(h1, V[m]); if (~u && ~v) { pss[h0][h1].emplace_back(u, v); } } } // for(int h0=0;h0<3;++h0)for(int h1=h0;h1<3;++h1)cerr<<"pss["<<h0<<"]["<<h1<<"] = "<<pss[h0][h1]<<endl; // (h, h) vector<int> fss[3], gss[3]; for (int h = 0; h < 3; ++h) { fss[h].assign(N[h] + 1, 0); for (const auto &p : pss[h][h]) { ++fss[h][p.first]; --fss[h][p.second]; } for (int x = 0; x < N[h]; ++x) { fss[h][x + 1] += fss[h][x]; } gss[h].assign(N[h] + 1, 0); for (int x = 0; x < N[h]; ++x) { gss[h][x + 1] = gss[h][x] + ((!fss[h][x]) ? 1 : 0); } } vector<int> lsss[3][3], rsss[3][3]; for (int h0 = 0; h0 < 3; ++h0) for (int h1 = h0; h1 < 3; ++h1) { lsss[h0][h1].assign(N[0], 0); rsss[h0][h1].assign(N[0], N[h1]); for (const auto &p : pss[h0][h1]) { if (0 < p.first) { chmin(rsss[h0][h1][p.first - 1], p.second); } if (p.first < N[h1]) { chmax(lsss[h0][h1][p.first], p.second); } } for (int x = 0; x < N[h1] - 1; ++x) { chmax(lsss[h0][h1][x + 1], lsss[h0][h1][x]); } for (int x = N[h1]; --x >= 1; ) { chmin(rsss[h0][h1][x - 1], rsss[h0][h1][x]); } // cerr<<"lsss["<<h0<<"]["<<h1<<"] = "<<lsss[h0][h1]<<endl; // cerr<<"rsss["<<h0<<"]["<<h1<<"] = "<<rsss[h0][h1]<<endl; } { const int h0 = 2; const int h1 = 1; lsss[h0][h1].assign(N[0], 0); rsss[h0][h1].assign(N[0], N[h1]); for (const auto &p : pss[h1][h0]) { // ! if (0 < p.second) { chmin(rsss[h0][h1][p.second - 1], p.first); } if (p.second < N[h1]) { chmax(lsss[h0][h1][p.second], p.first); } } for (int x = 0; x < N[h1] - 1; ++x) { chmax(lsss[h0][h1][x + 1], lsss[h0][h1][x]); } for (int x = N[h1]; --x >= 1; ) { chmin(rsss[h0][h1][x - 1], rsss[h0][h1][x]); } // cerr<<"lsss["<<h0<<"]["<<h1<<"] = "<<lsss[h0][h1]<<endl; // cerr<<"rsss["<<h0<<"]["<<h1<<"] = "<<rsss[h0][h1]<<endl; } // (1, 2) vector<int> headss[3]; vector<Int> sumss[3]; for (int h = 1; h < 3; ++h) { headss[h].assign(N[h] + 1, 0); for (int x = 0; x < N[h]; ++x) { headss[h][x + 1] = (x + 1 < N[h] && lsss[h][h ^ 3][x] == lsss[h][h ^ 3][x + 1]) ? headss[h][x] : (x + 1); } sumss[h].assign(N[h] + 1, 0); for (int x = 0; x < N[h]; ++x) { sumss[h][x + 1] = sumss[h][x] + ((!fss[h][x]) ? max(rsss[h][h ^ 3][x] - lsss[h][h ^ 3][x], 0) : 0); } } auto calc = [&](int x1, int x2) -> Int { Int ret = 0; if (x2 == N[2] || x1 < lsss[2][1][x2]) { ret += sumss[1][x1]; } else if (x1 == N[1] || x2 < lsss[1][2][x1]) { ret += sumss[2][x2]; } else { const int xx1 = headss[1][x1]; const int xx2 = headss[2][x2]; ret += sumss[1][x1]; ret += (Int)(gss[1][x1] - gss[1][xx1]) * (gss[2][x2] - gss[2][xx2]); } return ret; }; Int ans = 0; for (int x0 = 0; x0 < N[0]; ++x0) if (!fss[0][x0]) { if (lsss[0][1][x0] < rsss[0][1][x0] && lsss[0][2][x0] < rsss[0][2][x0]) { ans += calc(lsss[0][1][x0], lsss[0][2][x0]); ans -= calc(lsss[0][1][x0], rsss[0][2][x0]); ans -= calc(rsss[0][1][x0], lsss[0][2][x0]); ans += calc(rsss[0][1][x0], rsss[0][2][x0]); } } printf("%lld\n", ans); } return 0; }