結果

問題 No.488 四角関係
コンテスト
ユーザー yuppe19 😺
提出日時 2017-02-24 22:52:59
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 827 ms / 5,000 ms
コード長 950 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,395 ms
コンパイル使用メモリ 187,108 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:09:20
合計ジャッジ時間 6,799 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   int n, m; scanf("%d%d", &n, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~
main.cpp:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     int a, b; scanf("%d%d", &a, &b);
      |               ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
using i64 = long long;

int main(void) {
  int n, m; scanf("%d%d", &n, &m);
  vector<vector<bool>> G(n, vector<bool>(n, false)); // G[n][n]
  for(int i=0; i<m; ++i) {
    int a, b; scanf("%d%d", &a, &b);
    G[a][b] = true;
    G[b][a] = true;
  }

  set<vector<int>> resultSet;
  for(int a=0; a<n; ++a) {
    for(int b=0; b<n; ++b) {
      for(int c=0; c<n; ++c) {
        for(int d=0; d<n; ++d) {
          set<int> sett;
          sett.insert(a);
          sett.insert(b);
          sett.insert(c);
          sett.insert(d);
          if(sett.size() != 4) { continue; }
          if(G[a][b] && G[b][c] && G[c][d] && G[d][a] && !G[a][c] && !G[b][d]) {
            vector<int> v = {a, b, c, d};
            sort(begin(v), end(v));
            resultSet.insert(v);
          }
        }
      }
    }
  }
  int cnt = resultSet.size();
  printf("%d\n", cnt);

  return 0;
}
0