結果

問題 No.3029 オイラー標数
ユーザー drazerd
提出日時 2025-03-18 07:46:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 85,428 KB
実行使用メモリ 37,888 KB
最終ジャッジ日時 2025-03-18 07:46:16
合計ジャッジ時間 11,437 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <tuple>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int q;
    cin >> q;

    set<int> V;  // Unique vertices
    set<pair<int, int>> E;  // Unique edges
    set<tuple<int, int, int>> F;  // Unique faces

    for (int i = 0; i < q; i++) {
        int a, b, c;
        cin >> a >> b >> c;

        // Insert vertices
        V.insert(a);
        V.insert(b);
        V.insert(c);

        // Insert edges (always store as (smaller, larger))
        E.insert({a, b});
        E.insert({b, c});
        E.insert({a, c});

        // Insert faces (automatically sorted in tuple)
        F.insert({a, b, c});
    }
    long long ans =  V.size() - E.size() + F.size();
    cout << ans << "\n";

    return 0;
}
0