結果

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

ソースコード

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});
    }

    cout << V.size() - E.size() + F.size() << "\n";

    return 0;
}
0