結果
問題 | No.3031 曲面の向き付け |
ユーザー |
![]() |
提出日時 | 2025-02-21 21:50:12 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 297 ms / 2,000 ms |
コード長 | 1,539 bytes |
コンパイル時間 | 4,359 ms |
コンパイル使用メモリ | 303,968 KB |
実行使用メモリ | 22,912 KB |
最終ジャッジ日時 | 2025-02-21 21:50:38 |
合計ジャッジ時間 | 8,907 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h>namespace {#pragma GCC diagnostic ignored "-Wunused-function"#include<atcoder/all>#pragma GCC diagnostic warning "-Wunused-function"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>;} int main() {ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;bool ok = true;dsu uf(2 * n);map<P, P> mp;rep(i, n) {int a, b, c;cin >> a >> b >> c;for (auto [u, v] : {pair(a, b), {b, c}, {c, a}}) {int ni = i;if (u > v) ni = ~ni, swap(u, v);auto [it, inserted] = mp.emplace(pair(u, v), pair(ni, 1));if (inserted) continue;if (it->second.second >= 2) {ok = false;break;}it->second.second++;int j = it->second.first;bool diff = (ni < 0) ^ (j < 0);if (j < 0) j = ~j;if (diff) uf.merge(i, j), uf.merge(i + n, j + n);else uf.merge(i, j + n), uf.merge(i + n, j);}}bool ans = ok;rep(i, n) ans &= !uf.same(i, n + i);cout << (ans ? "YES\n" : "NO\n");}