結果

問題 No.488 四角関係
ユーザー a01sa01to
提出日時 2025-07-08 00:44:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3,511 ms / 5,000 ms
コード長 1,032 bytes
コンパイル時間 3,347 ms
コンパイル使用メモリ 293,376 KB
実行使用メモリ 46,592 KB
最終ジャッジ日時 2025-07-08 00:44:25
合計ジャッジ時間 8,324 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector Graph(n, vector<bool>(n, false));
  rep(_, m) {
    int u, v;
    cin >> u >> v;
    Graph[u][v] = Graph[v][u] = true;
  }
  set<vector<int>> ans, mans;
  rep(u, n) rep(v, n) rep(w, n) {
    if (u == v || u == w || v == w) continue;
    bool flg = false;
    if (Graph[u][v] && Graph[v][w] && Graph[w][u]) flg = true;
    rep(x, n) {
      if (x == u || x == v || x == w) continue;
      if (Graph[u][v] && Graph[v][w] && Graph[w][x] && Graph[x][u]) {
        vector<int> cycle = { u, v, w, x };
        sort(cycle.begin(), cycle.end());
        ans.insert(cycle);
        if (flg) mans.insert(cycle);
      }
    }
  }
  for (auto& c : mans) ans.erase(c);
  cout << ans.size() << '\n';
  return 0;
}
0