結果
| 問題 |
No.488 四角関係
|
| コンテスト | |
| ユーザー |
yun_app
|
| 提出日時 | 2017-03-08 15:17:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 5,000 ms |
| コード長 | 1,968 bytes |
| コンパイル時間 | 2,837 ms |
| コンパイル使用メモリ | 77,588 KB |
| 実行使用メモリ | 39,324 KB |
| 最終ジャッジ日時 | 2024-06-23 19:00:24 |
| 合計ジャッジ時間 | 5,130 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
/* 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;
}
}
yun_app