結果

問題 No.488 四角関係
ユーザー yukicoder
提出日時 2017-02-25 01:58:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 1,487 bytes
コンパイル時間 2,119 ms
コンパイル使用メモリ 104,832 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2025-01-03 08:34:14
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Numerics;
public class Program
{
    static bool checkSquare(bool[,] edge, int i, int j, int k, int l)
    {
        return edge[i, j] && edge[j, k] && edge[k, l] && edge[l, i] && !edge[i, k] && !edge[j, l];
    }
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);

        bool[,] edge = new bool[N, N];
        for (int i = 0; i < M; i++)
        {
            string[] p = Console.ReadLine().Split();
            int a = int.Parse(p[0]);
            int b = int.Parse(p[1]);
            edge[a, b] = true;
            edge[b, a] = true;
        }
        int count = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                for (int k = j + 1; k < N; k++)
                {
                    for (int l = k + 1; l < N; l++)
                    {
                        if (checkSquare(edge, i, j, k, l))
                        {
                            count++;
                        }
                        if (checkSquare(edge, i, k, l, j))
                        {
                            count++;
                        }
                        if (checkSquare(edge, i, l, j, k))
                        {
                            count++;
                        }
                    }
                }
            }
        }
        Console.WriteLine(count);

    }
}
0