結果

問題 No.488 四角関係
ユーザー yun_appyun_app
提出日時 2017-03-08 15:17:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 1,968 bytes
コンパイル時間 4,048 ms
コンパイル使用メモリ 73,492 KB
実行使用メモリ 52,404 KB
最終ジャッジ日時 2023-09-05 23:50:49
合計ジャッジ時間 5,967 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
52,104 KB
testcase_01 AC 61 ms
49,824 KB
testcase_02 AC 63 ms
51,960 KB
testcase_03 AC 51 ms
49,212 KB
testcase_04 AC 59 ms
50,912 KB
testcase_05 AC 67 ms
51,532 KB
testcase_06 AC 64 ms
51,932 KB
testcase_07 AC 90 ms
52,356 KB
testcase_08 AC 88 ms
52,404 KB
testcase_09 AC 42 ms
49,304 KB
testcase_10 AC 49 ms
49,236 KB
testcase_11 AC 44 ms
49,280 KB
testcase_12 AC 49 ms
49,236 KB
testcase_13 AC 47 ms
49,320 KB
testcase_14 AC 44 ms
49,316 KB
testcase_15 AC 43 ms
49,176 KB
testcase_16 AC 42 ms
49,176 KB
testcase_17 AC 43 ms
49,204 KB
testcase_18 AC 43 ms
49,344 KB
testcase_19 AC 43 ms
49,488 KB
testcase_20 AC 44 ms
49,348 KB
testcase_21 AC 43 ms
49,688 KB
testcase_22 AC 43 ms
49,284 KB
testcase_23 AC 43 ms
49,280 KB
testcase_24 AC 43 ms
49,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    
    
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int N = Integer.parseInt(lines[0]);
        int M = Integer.parseInt(lines[1]);
        
        int[][] nodeMap = new int[N][N];
        int a,b;
        for(int i=0;i<M;i++){
            lines = br.readLine().split(" ");
            a = Math.min(Integer.parseInt(lines[0]),Integer.parseInt(lines[1]));
            b = Math.max(Integer.parseInt(lines[0]),Integer.parseInt(lines[1]));
            nodeMap[a][b] = 1;
        }
        
        int ans = 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++){
                        ans += check(nodeMap,i,j,k,l);
                    }
                }
            }
        }
        System.out.println(ans);
    }
    
    private static int check(int[][] nodeMap,int i,int j,int k,int l){
        if(nodeMap[i][j] == 1
        && nodeMap[i][k] == 0
        && nodeMap[i][l] == 1
        && nodeMap[j][k] == 1
        && nodeMap[j][l] == 0
        && nodeMap[k][l] == 1){
            return 1;
        }
        if(nodeMap[i][j] == 0
        && nodeMap[i][k] == 1
        && nodeMap[i][l] == 1
        && nodeMap[j][k] == 1
        && nodeMap[j][l] == 1
        && nodeMap[k][l] == 0){
            return 1;
        }
        if(nodeMap[i][j] == 1
        && nodeMap[i][k] == 1
        && nodeMap[i][l] == 0
        && nodeMap[j][k] == 0
        && nodeMap[j][l] == 1
        && nodeMap[k][l] == 1){
            return 1;
        }
        return 0;
    }
    
}
0