結果

問題 No.488 四角関係
ユーザー syaro
提出日時 2017-03-03 20:08:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 765 bytes
コンパイル時間 1,406 ms
コンパイル使用メモリ 167,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 05:16:51
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main() {
    cin.tie(0);
    //ios::sync_with_stdio(0);

    int N; cin >> N;
    int M; cin >> M;
    vector<set<int>> P(N);
    for(int i = 0; i < M; i++) {
        int a; cin >> a;
        int b; cin >> b;
        P[a].insert(b);
        P[b].insert(a);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) for(int j: P[i]) if(i < j) for(int k: P[j]) if(i < k) {
        if(P[i].count(k)) continue;
        for(int l: P[k]) if(j < l) {
            if(not P[j].count(l) and P[i].count(l)) {
                if(0) { //dbg
                    cout << i << ' ' << j << ' ' << k << ' ' << l << '\n';
                }
                ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
0