結果

問題 No.488 四角関係
ユーザー goodbatongoodbaton
提出日時 2017-06-05 00:12:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 1,427 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 04:46:24
合計ジャッジ時間 1,937 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,348 KB
testcase_01 AC 4 ms
4,348 KB
testcase_02 AC 5 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 6 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 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 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 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 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |   scanf("%d%d",&n,&m);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:48:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |     scanf("%d%d",&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,m;
  int dist[100][100];

  scanf("%d%d",&n,&m);

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      dist[i][j] = INF;
    }
    dist[i][i] = 0;
  }
  
  for(int i=0;i<m;i++){
    int a,b;

    scanf("%d%d",&a,&b);

    dist[a][b] = dist[b][a] = 1;
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(dist[i][j] == 2){
        
        for(int p=0;p<n;p++){
          for(int q=p+1;q<n;q++){
            if(dist[p][q] == 2 && dist[i][q] == 1 &&
               dist[j][q] == 1 && dist[i][p] == 1 &&
               dist[j][p] == 1){
              ans++;
            }
          }
        }
        
      }
      
    }
  }

  printf("%d\n",ans/2);
  
  return 0;
}
0