結果

問題 No.3029 オイラー標数
ユーザー bal4u
提出日時 2025-03-04 19:23:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 2,696 ms
コンパイル使用メモリ 211,212 KB
実行使用メモリ 33,468 KB
最終ジャッジ日時 2025-03-04 19:24:06
合計ジャッジ時間 12,865 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct PairHash {
    size_t operator()(const pair<int,int>& p) const {
        return ((size_t)p.first) * 31ULL + (size_t)p.second;
    }
};

struct TripleHash {
    size_t operator()(const tuple<int,int,int>& t) const {
        auto [a, b, c] = t;
        size_t h1 = std::hash<int>()(a);
        size_t h2 = std::hash<int>()(b);
        size_t h3 = std::hash<int>()(c);
        return h1 * 131ULL + h2 * 137ULL + h3;
    }
};

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

    int Q;
    cin >> Q;

    unordered_set<int> V;
    unordered_set<pair<int,int>, PairHash> E;
    unordered_set<tuple<int,int,int>, TripleHash> F;

    for (int i = 0; i < Q; i++){
        int a, b, c;
        cin >> a >> b >> c;
        V.insert(a);
        V.insert(b);
        V.insert(c);

        E.insert({a, b});
        E.insert({b, c});
        E.insert({a, c});

        F.insert({a, b, c});
    }

    int ans = V.size() - E.size() + F.size();
    cout << ans << endl;
    return 0;
}
0