結果
問題 | No.274 The Wall |
ユーザー | syndrome |
提出日時 | 2023-06-10 00:49:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 4,038 bytes |
コンパイル時間 | 2,125 ms |
コンパイル使用メモリ | 215,484 KB |
実行使用メモリ | 131,968 KB |
最終ジャッジ日時 | 2024-06-10 15:36:50 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 132 ms
69,760 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 376 ms
131,968 KB |
testcase_12 | AC | 14 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 8 ms
5,376 KB |
testcase_16 | AC | 57 ms
27,008 KB |
testcase_17 | AC | 55 ms
26,624 KB |
testcase_18 | AC | 59 ms
27,776 KB |
testcase_19 | AC | 12 ms
5,376 KB |
testcase_20 | AC | 15 ms
5,376 KB |
testcase_21 | AC | 14 ms
5,376 KB |
testcase_22 | AC | 16 ms
5,376 KB |
testcase_23 | AC | 16 ms
5,376 KB |
testcase_24 | AC | 14 ms
5,376 KB |
testcase_25 | AC | 16 ms
5,376 KB |
ソースコード
// (◕ᴗ◕✿) #include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; // using mint = modint1000000007; // using mint = modint998244353; // using vmint = vc<mint>;using vvmint = vc<vmint>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define srep(i, s, n) for (int i = s; i < n; i++) #define drep(i, n) for (int i = n; i >= 0; i--) #define dsrep(i, s, n) for (int i = s; i >= n; i--) #define len(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl using namespace std; template<typename T> using vc = vector<T>; template<typename T> using vv = vc<vc<T>>; using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>; using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>; using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>; using uint = unsigned int; using ull = unsigned long long; using pii = pair<int, int>; const double pi = 3.141592653589793; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; // const int mod = 1000000007; const int mod = 998244353; inline bool inside(long long y, long long x, long long H, long long W) {return 0 <= y and y < H and 0 <= x and x < W; } struct phash{ inline size_t operator()(const pair<int,int> & p) const{ const auto h1 = hash<int>()(p.first); const auto h2 = hash<int>()(p.second); return h1 ^ (h2 << 1); } }; struct twosat{ public : twosat(int n) : nn(n){ _n = 2 * nn; group = vi(_n, -1); order = vi(); order.clear(); g = vvi(_n); rg = vvi(_n); label = 0; answer = vc<bool>(nn); } void add_edge(int u, int v){ g[u].push_back(v); rg[v].push_back(u); } void dfs(int s){ used[s] = true; for (auto t : g[s]){ if (!used[t]) dfs(t); } order.push_back(s); } void rdfs(int s, int color){ group[s] = color; nused[s] = true; for (auto t : rg[s]){ if (!nused[t]) rdfs(t, color); } } void scc(){ used = vc<bool>(_n); nused = vc<bool>(_n); rep(i, _n){ if (!used[i]) dfs(i); } drep(i, len(order) - 1){ if (!nused[order[i]]){ rdfs(order[i], label); label++; } } } void add(int i, bool f, int j, bool g){ add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0)); add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0)); } bool judge(){ scc(); rep(i, nn){ if (group[2 * i] == group[2 * i + 1]) return false; answer[i] = group[2 * i] < group[2 * i + 1]; } return true; } vc<bool> restore(){ return answer; } private : int _n, nn, label; vi order, group; vvi g, rg; vc<bool> used, nused, answer; }; int main(){ int N, M; cin >> N >> M; vc<pair<int, int>> pincs; rep(i, N){ int l, r; cin >> l >> r; pincs.push_back({l, r}); } twosat ts(N); rep(j, N) rep(i, j){ auto [l1, r1] = pincs[i]; auto [l2, r2] = pincs[j]; if (max(l1, l2) <= min(r1, r2)){ ts.add(i, 0, j, 0); } if (max(l1, M - 1 - r2) <= min(r1, M - 1 - l2)){ ts.add(i, 0, j, 1); } if (max(M - 1 - r1, l2) <= min(M - 1 - l1, r2)){ ts.add(i, 1, j, 0); } if (max(M - 1 - r1, M - 1 - r2) <= min(M - 1 - l1, M - 1 - l2)){ ts.add(i, 1, j, 1); } } if (ts.judge()) cout << "YES" << endl; else cout << "NO" << endl; }