結果

問題 No.1340 おーじ君をさがせ
ユーザー SSRSSSRS
提出日時 2021-01-15 22:26:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,092 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 175,644 KB
実行使用メモリ 18,104 KB
最終ジャッジ日時 2023-08-17 19:55:02
合計ジャッジ時間 13,095 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,368 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 4 ms
4,760 KB
testcase_03 AC 4 ms
4,772 KB
testcase_04 AC 6 ms
5,996 KB
testcase_05 AC 4 ms
4,708 KB
testcase_06 AC 5 ms
5,168 KB
testcase_07 AC 5 ms
4,944 KB
testcase_08 AC 5 ms
5,304 KB
testcase_09 AC 5 ms
5,120 KB
testcase_10 AC 11 ms
6,020 KB
testcase_11 AC 5 ms
4,412 KB
testcase_12 AC 13 ms
8,068 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 10 ms
5,212 KB
testcase_15 AC 7 ms
4,512 KB
testcase_16 AC 11 ms
6,728 KB
testcase_17 AC 8 ms
4,480 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 6 ms
4,436 KB
testcase_20 AC 8 ms
6,080 KB
testcase_21 AC 438 ms
11,008 KB
testcase_22 AC 295 ms
13,416 KB
testcase_23 AC 679 ms
12,504 KB
testcase_24 AC 142 ms
15,400 KB
testcase_25 AC 658 ms
8,452 KB
testcase_26 AC 420 ms
8,064 KB
testcase_27 AC 210 ms
6,624 KB
testcase_28 AC 620 ms
9,380 KB
testcase_29 AC 269 ms
5,644 KB
testcase_30 AC 446 ms
11,260 KB
testcase_31 AC 720 ms
18,104 KB
testcase_32 AC 16 ms
4,568 KB
testcase_33 AC 16 ms
4,588 KB
testcase_34 AC 21 ms
5,472 KB
testcase_35 AC 252 ms
10,108 KB
testcase_36 AC 5 ms
5,304 KB
testcase_37 AC 451 ms
4,836 KB
testcase_38 AC 681 ms
5,504 KB
testcase_39 AC 363 ms
11,256 KB
testcase_40 AC 367 ms
11,208 KB
testcase_41 AC 369 ms
11,212 KB
testcase_42 AC 5 ms
5,368 KB
testcase_43 AC 5 ms
4,400 KB
testcase_44 AC 4 ms
4,440 KB
testcase_45 AC 5 ms
5,300 KB
testcase_46 AC 140 ms
15,056 KB
testcase_47 AC 141 ms
15,040 KB
testcase_48 AC 203 ms
17,776 KB
testcase_49 AC 19 ms
11,004 KB
testcase_50 AC 20 ms
11,004 KB
testcase_51 AC 34 ms
17,216 KB
testcase_52 AC 11 ms
5,740 KB
testcase_53 AC 12 ms
5,620 KB
testcase_54 WA -
testcase_55 AC 140 ms
11,924 KB
testcase_56 AC 4 ms
5,172 KB
testcase_57 AC 5 ms
5,300 KB
testcase_58 AC 5 ms
4,916 KB
testcase_59 AC 27 ms
15,276 KB
testcase_60 AC 4 ms
4,644 KB
testcase_61 AC 39 ms
18,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int MAX;
  if (mt() % 2 == 0){
    MAX = 20000;
  } else {
    MAX = 30000;
  }
  int N, M;
  long long T;
  cin >> N >> M >> T;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    E[a].push_back(b);
  }
  vector<vector<bool>> dp(MAX + 1, vector<bool>(N, false));
  dp[0][0] = true;
  vector<vector<int>> p(N);
  for (int i = 0; i < MAX; i++){
    for (int j = 0; j < N; j++){
      if (dp[i][j]){
        p[j].push_back(i);
        for (int k : E[j]){
          dp[i + 1][k] = true;
        }
      }
    }
  }
  int ans = 0;
  if (T <= MAX){
    for (int i = 0; i < N; i++){
      if (dp[T][i]){
        ans++;
      }
    }    
  } else {
    for (int i = 0; i < N; i++){
      if (p[i].size() >= 2){
        int a = p[i][p[i].size() - 2];
        int b = p[i][p[i].size() - 1];
        int d = b - a;
        if (b + d >= MAX){
          if (T % d == a % d){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
0