結果
| 問題 |
No.3029 オイラー標数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-21 22:24:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 779 ms / 2,000 ms |
| コード長 | 1,492 bytes |
| コンパイル時間 | 1,146 ms |
| コンパイル使用メモリ | 94,492 KB |
| 実行使用メモリ | 38,016 KB |
| 最終ジャッジ日時 | 2025-02-21 22:24:37 |
| 合計ジャッジ時間 | 13,423 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Q;
cin >> Q;
set<int> vertices;
set<pair<int, int>> edges;
set<tuple<int, int, int>> faces;
int v_count = 0, e_count = 0, f_count = 0;
while (Q--) {
int a, b, c;
cin >> a >> b >> c;
// 处理顶点
int new_v = 0;
if (!vertices.count(a)) { vertices.insert(a); new_v++; }
if (!vertices.count(b)) { vertices.insert(b); new_v++; }
if (!vertices.count(c)) { vertices.insert(c); new_v++; }
v_count += new_v;
// 处理边(自动排序)
auto e1 = make_pair(min(a, b), max(a, b));
auto e2 = make_pair(min(b, c), max(b, c));
auto e3 = make_pair(min(c, a), max(c, a));
int new_e = 0;
if (!edges.count(e1)) { edges.insert(e1); new_e++; }
if (!edges.count(e2)) { edges.insert(e2); new_e++; }
if (!edges.count(e3)) { edges.insert(e3); new_e++; }
e_count += new_e;
// 处理面(全排序)
int x = min({a, b, c});
int z = max({a, b, c});
int y = a + b + c - x - z;
auto f = make_tuple(x, y, z);
if (!faces.count(f)) {
faces.insert(f);
f_count++;
}
}
cout << v_count - e_count + f_count << endl;
return 0;
}