結果

問題 No.488 四角関係
ユーザー tatuyan_edsontatuyan_edson
提出日時 2017-02-24 09:55:25
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 976 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 26,536 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 23:02:18
合計ジャッジ時間 1,487 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>

int main(void){
  int N,M,num=0;
  int edges[2];
  char mat[50][50]={{0}};
  int i,j,k,l,flg;
  
  scanf("%d%d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d%d",&edges[0],&edges[1]);
    mat[edges[0]][edges[1]]=mat[edges[1]][edges[0]]=1;
  }

  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(k=j+1;k<N;k++){
	if(!((mat[i][j]==1 && mat[j][k]==1 && mat[k][i]==0)
	     || (mat[j][k]==1 && mat[k][i]==1 && mat[i][j]==0)
	     || (mat[k][i]==1 && mat[i][j]==1 && mat[j][k]==0))) continue;
	if(mat[k][i]==0) flg=1;
	if(mat[i][j]==0) flg=2;
	if(mat[j][k]==0) flg=3;
	for(l=k+1;l<N;l++){
	  switch(flg){
	  case 1:
	    if(mat[j][l]==0 && mat[i][l]==1 && mat[k][l]==1){
	      num++;
	    }
	    break;
	  case 2:
	    if(mat[k][l]==0 && mat[j][l]==1 && mat[i][l]==1){
	      num++;
	    }
	    break;
	  case 3:
	    if(mat[i][l]==0 && mat[k][l]==1 && mat[j][l]==1){
	      num++;
	    }
	    break;
	  }
	}
      }
    }
  }
  printf("%d\n",num);
  return 0;
}
0