結果

問題 No.488 四角関係
ユーザー どららどらら
提出日時 2017-02-24 22:54:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 1,077 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 164,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 23:37:44
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M;
int G[55][55];
map<vector<int>,int> ret;
int v[4];

void dfs(int n){
  if(n == 4){
    if(G[v[0]][v[1]]==1 && G[v[1]][v[2]]==1 && G[v[2]][v[3]]==1 && G[v[3]][v[0]]==1 &&
       G[v[0]][v[2]]==0 && G[v[1]][v[3]]==0){
      map<int,int> cnt;
      cnt[v[0]] = 1;
      cnt[v[1]] = 1;
      cnt[v[2]] = 1;
      cnt[v[3]] = 1;
      if(cnt.size() != 4) return;
      
      vector<int> w;
      w.push_back(v[0]);
      w.push_back(v[1]);
      w.push_back(v[2]);
      w.push_back(v[3]);
      sort(ALLOF(w));
      ret[w]=1;
    }
    return;
  }

  rep(i,N){
    v[n] = i;
    dfs(n+1);
  }
}

int main(){

  cin >> N >> M;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  
  dfs(0);

  cout << ret.size() << endl;
  return 0;
}

0