Submission #1604487


Source Code Expand

#include <iostream>
#include <algorithm>
using namespace std;

using ll = long long;

int main() {
  // 入力
  int N, M;
  cin >> N >> M;
  int x[M], y[M];
  for (int i = 0; i < M; i++) cin >> x[i] >> y[i];

  // 部分点解法
  // Nの順列を生成するたび、条件を満たすかM回確認すれば良い
  int n[N];
  for (int i = 0; i < N; i++) n[i] = i + 1;
  int ans = 0;
  do {
    bool flag = true;
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < N; j++) {
        if (n[j] == y[i]) flag = false;
        else if (n[j] == x[i]) break;
      }
    }
    if (flag) ans++;
  } while (next_permutation(n, n + N));

  // 解答
  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task D - 徒競走
User university
Language C++14 (GCC 5.4.1)
Score 30
Code Size 725 Byte
Status TLE
Exec Time 3155 ms
Memory 256 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 30 / 30 0 / 70
Status
AC × 2
TLE × 1
AC × 15
AC × 15
TLE × 17
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
Subtask1 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt TLE 3155 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 2 ms 256 KB
1_02.txt AC 15 ms 256 KB
1_03.txt AC 12 ms 256 KB
1_04.txt AC 8 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 3 ms 256 KB
1_08.txt AC 2 ms 256 KB
1_09.txt AC 8 ms 256 KB
1_10.txt AC 11 ms 256 KB
1_11.txt AC 2 ms 256 KB
1_12.txt AC 13 ms 256 KB
2_00.txt TLE 3155 ms 256 KB
2_01.txt TLE 3155 ms 256 KB
2_02.txt TLE 3155 ms 256 KB
2_03.txt TLE 3155 ms 256 KB
2_04.txt TLE 3155 ms 256 KB
2_05.txt TLE 3155 ms 256 KB
2_06.txt TLE 3155 ms 256 KB
2_07.txt TLE 3155 ms 256 KB
2_08.txt TLE 3155 ms 256 KB
2_09.txt TLE 3155 ms 256 KB
2_10.txt TLE 3155 ms 256 KB
2_11.txt TLE 3155 ms 256 KB
2_12.txt TLE 3155 ms 256 KB
2_13.txt TLE 3155 ms 256 KB
2_14.txt TLE 3155 ms 256 KB
2_15.txt TLE 3155 ms 256 KB