結果

問題 No.1147 土偶Ⅱ
ユーザー ninoinuininoinui
提出日時 2020-08-07 03:14:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 500 ms
コード長 717 bytes
コンパイル時間 1,966 ms
コンパイル使用メモリ 204,712 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 18:05:26
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  vector<set<int>> V(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b);
    G.at(b).push_back(a);
    V.at(a).insert(b);
    V.at(b).insert(a);
  }
  int ans = 0;
  auto f = [&](int i, int j) {
    if (V.at(i).count(j)) return true;
    for (auto g : G.at(i)) if (V.at(g).count(j)) return false;
    return true;
  };
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (!f(j, i)) continue;
      for (int k = 0; k < j; k++) {
        if (!f(k, i)) continue;
        if (!f(k, j)) continue;
        ans++;
      }
    }
  }
  cout << ans << "\n";
}
0