結果

問題 No.488 四角関係
ユーザー ikdikd
提出日時 2017-02-25 00:16:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 66,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-31 01:04:43
合計ジャッジ時間 2,076 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int g[50][50];

int main(){

   int N, M;
   cin>> N>> M;
   int a[M], b[M];
   for(int i=0; i<M; i++){
      cin>> a[i]>> b[i];
      g[a[i]][b[i]]=g[b[i]][a[i]]=1;
   }

   int r=0;
   for(int s=0; s<N; s++){
      for(int t=s+1; t<N; t++){
         for(int u=t+1; u<N; u++){
            for(int v=u+1; v<N; v++){
               vector<int> x={s, t, u, v};
               sort(x.begin(), x.end());
               do{
                  if(g[x[0]][x[1]]&&g[x[1]][x[2]]&&g[x[2]][x[3]]&&g[x[3]][x[0]]){
                     if(!g[x[0]][x[2]]&&(!g[x[1]][x[3]])){
                        r++;
                        break;
                     }
                  }
               }while(next_permutation(x.begin(), x.end()));
            }
         }
      }
   }

   cout<< r<< endl;
}
0