結果

問題 No.1340 おーじ君をさがせ
ユーザー SSRSSSRS
提出日時 2021-01-15 22:28:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,029 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 176,264 KB
実行使用メモリ 18,176 KB
最終ジャッジ日時 2024-05-05 02:50:56
合計ジャッジ時間 14,211 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,144 KB
testcase_01 AC 6 ms
5,504 KB
testcase_02 AC 5 ms
5,632 KB
testcase_03 AC 6 ms
5,504 KB
testcase_04 AC 6 ms
6,016 KB
testcase_05 AC 5 ms
5,504 KB
testcase_06 AC 6 ms
6,016 KB
testcase_07 AC 6 ms
5,760 KB
testcase_08 AC 5 ms
5,504 KB
testcase_09 AC 5 ms
5,504 KB
testcase_10 AC 16 ms
6,912 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 18 ms
9,600 KB
testcase_13 AC 8 ms
5,504 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 11 ms
5,504 KB
testcase_16 AC 15 ms
8,064 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
testcase_19 AC 7 ms
5,504 KB
testcase_20 AC 11 ms
7,040 KB
testcase_21 AC 644 ms
13,056 KB
testcase_22 AC 442 ms
15,616 KB
testcase_23 AC 683 ms
12,672 KB
testcase_24 AC 207 ms
18,048 KB
testcase_25 AC 662 ms
8,704 KB
testcase_26 AC 422 ms
8,192 KB
testcase_27 AC 312 ms
8,064 KB
testcase_28 AC 624 ms
9,344 KB
testcase_29 AC 401 ms
6,784 KB
testcase_30 AC 680 ms
13,312 KB
testcase_31 AC 720 ms
18,176 KB
testcase_32 AC 23 ms
5,760 KB
testcase_33 AC 23 ms
5,504 KB
testcase_34 AC 23 ms
5,632 KB
testcase_35 AC 378 ms
11,776 KB
testcase_36 AC 5 ms
5,376 KB
testcase_37 AC 680 ms
5,632 KB
testcase_38 AC 688 ms
5,760 KB
testcase_39 AC 632 ms
17,152 KB
testcase_40 AC 608 ms
17,152 KB
testcase_41 AC 606 ms
17,152 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 6 ms
5,504 KB
testcase_45 AC 5 ms
5,376 KB
testcase_46 AC 204 ms
17,920 KB
testcase_47 AC 204 ms
17,920 KB
testcase_48 AC 204 ms
18,048 KB
testcase_49 AC 33 ms
17,152 KB
testcase_50 AC 34 ms
17,024 KB
testcase_51 AC 34 ms
17,152 KB
testcase_52 WA -
testcase_53 AC 18 ms
6,912 KB
testcase_54 AC 17 ms
6,912 KB
testcase_55 AC 139 ms
11,776 KB
testcase_56 AC 6 ms
6,016 KB
testcase_57 AC 7 ms
6,016 KB
testcase_58 AC 6 ms
5,632 KB
testcase_59 AC 37 ms
18,048 KB
testcase_60 AC 5 ms
5,504 KB
testcase_61 AC 39 ms
18,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int 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