結果

問題 No.488 四角関係
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-03-21 12:17:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,264 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 62,880 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 05:10:29
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <stack>
using ll = long long;
#define MOD 1000000007
using namespace std;

bool tree[60][60];

bool f(bool a, bool b, bool c) {
    return (a || b || c) && (!a ^ b ^ c);
}

bool square(int v1, int v2, int v3, int v4) {
    if (f(tree[v1][v2], tree[v1][v3], tree[v1][v4])) {
        if (f(tree[v1][v2], tree[v2][v3], tree[v2][v4])) {
            if (f(tree[v3][v2], tree[v1][v3], tree[v3][v4])) {
                if (f(tree[v4][v2], tree[v4][v3], tree[v1][v4])) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main(){
    int N, M, cnt = 0;
    cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        int a,b;
        cin >> a >> b;
        tree[a][b] = tree[b][a] = true;
    }
    for(int v1 = 0; v1 < N-3; v1++)
    {
        for(int v2 = v1 + 1; v2 < N-2; v2++)
        {
            for(int v3 = v2 + 1; v3 < N-1; v3++)
            {
                for(int v4 = v3 + 1; v4 < N; v4++)
                {
                    if (square(v1,v2,v3,v4)) {
                        cnt++;
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}
0