結果

問題 No.1340 おーじ君をさがせ
ユーザー SSRSSSRS
提出日時 2021-01-15 22:30:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,092 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 175,200 KB
実行使用メモリ 17,996 KB
最終ジャッジ日時 2023-08-17 20:17:10
合計ジャッジ時間 12,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,300 KB
testcase_01 AC 4 ms
4,520 KB
testcase_02 AC 4 ms
4,788 KB
testcase_03 AC 5 ms
5,444 KB
testcase_04 AC 4 ms
5,296 KB
testcase_05 AC 5 ms
5,492 KB
testcase_06 AC 4 ms
5,116 KB
testcase_07 AC 5 ms
5,460 KB
testcase_08 AC 4 ms
4,508 KB
testcase_09 AC 3 ms
4,396 KB
testcase_10 AC 10 ms
5,876 KB
testcase_11 AC 5 ms
4,440 KB
testcase_12 AC 18 ms
9,472 KB
testcase_13 AC 7 ms
5,180 KB
testcase_14 AC 9 ms
5,240 KB
testcase_15 AC 7 ms
4,440 KB
testcase_16 AC 11 ms
7,152 KB
testcase_17 AC 10 ms
5,132 KB
testcase_18 AC 6 ms
4,668 KB
testcase_19 AC 5 ms
4,656 KB
testcase_20 AC 10 ms
6,900 KB
testcase_21 AC 432 ms
11,084 KB
testcase_22 AC 435 ms
15,612 KB
testcase_23 AC 458 ms
11,024 KB
testcase_24 AC 142 ms
15,404 KB
testcase_25 AC 441 ms
7,392 KB
testcase_26 AC 420 ms
8,424 KB
testcase_27 AC 210 ms
6,680 KB
testcase_28 AC 620 ms
9,252 KB
testcase_29 AC 265 ms
5,616 KB
testcase_30 AC 450 ms
11,196 KB
testcase_31 AC 483 ms
15,428 KB
testcase_32 AC 17 ms
4,956 KB
testcase_33 AC 17 ms
4,664 KB
testcase_34 AC 16 ms
4,772 KB
testcase_35 AC 252 ms
9,972 KB
testcase_36 AC 3 ms
4,384 KB
testcase_37 AC 457 ms
4,896 KB
testcase_38 AC 457 ms
4,836 KB
testcase_39 AC 363 ms
11,308 KB
testcase_40 AC 602 ms
17,020 KB
testcase_41 AC 601 ms
17,152 KB
testcase_42 AC 4 ms
4,696 KB
testcase_43 AC 5 ms
5,244 KB
testcase_44 AC 6 ms
5,240 KB
testcase_45 AC 5 ms
5,296 KB
testcase_46 AC 203 ms
17,980 KB
testcase_47 AC 139 ms
15,108 KB
testcase_48 AC 203 ms
17,852 KB
testcase_49 AC 20 ms
10,936 KB
testcase_50 AC 19 ms
10,992 KB
testcase_51 AC 20 ms
11,032 KB
testcase_52 AC 11 ms
5,500 KB
testcase_53 AC 11 ms
5,444 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 5 ms
5,240 KB
testcase_57 AC 6 ms
6,236 KB
testcase_58 AC 5 ms
5,212 KB
testcase_59 AC 27 ms
15,288 KB
testcase_60 AC 4 ms
4,380 KB
testcase_61 AC 39 ms
17,996 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