結果

問題 No.488 四角関係
ユーザー suibaka_ku
提出日時 2017-03-19 16:15:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 960 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 95,524 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 23:38:41
合計ジャッジ時間 2,272 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <codecvt>
#include <locale>
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N, vector<int>(N));
    for(int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        g[a][b] = g[b][a] = 1;
    }
    int res = 0;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            for(int k=0; k<N; ++k) {
                for(int l=0; l<N; ++l) {
                    if(i == j || i == k || i == l || j == k || j == l || k == l) {
                        continue;
                    }
                    if(g[i][j] && g[j][k] && g[k][l] && g[l][i] && g[i][k] != 1 && g[j][l] != 1) {
                        res++;
                    }
                }
            }
        }
    }
    res /= 8;
    cout << res << endl;
}
0