結果

問題 No.1340 おーじ君をさがせ
ユーザー maspymaspy
提出日時 2020-09-26 16:03:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,174 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 65,024 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-05-05 02:29:42
合計ジャッジ時間 3,535 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
13,056 KB
testcase_01 WA -
testcase_02 AC 6 ms
13,184 KB
testcase_03 AC 8 ms
13,184 KB
testcase_04 AC 8 ms
13,056 KB
testcase_05 AC 7 ms
13,312 KB
testcase_06 AC 9 ms
13,184 KB
testcase_07 AC 9 ms
13,184 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 23 ms
13,312 KB
testcase_11 WA -
testcase_12 AC 10 ms
6,912 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 10 ms
6,912 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 15 ms
13,184 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 8 ms
5,376 KB
testcase_26 AC 7 ms
5,376 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 7 ms
5,376 KB
testcase_29 AC 13 ms
5,376 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 WA -
testcase_33 AC 6 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 6 ms
5,376 KB
testcase_36 RE -
testcase_37 AC 181 ms
5,376 KB
testcase_38 AC 6 ms
5,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 12 ms
13,184 KB
testcase_43 AC 10 ms
13,184 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 4 ms
5,376 KB
testcase_50 AC 5 ms
5,376 KB
testcase_51 AC 5 ms
5,376 KB
testcase_52 AC 4 ms
5,376 KB
testcase_53 AC 4 ms
5,376 KB
testcase_54 WA -
testcase_55 AC 3 ms
5,376 KB
testcase_56 AC 10 ms
13,184 KB
testcase_57 AC 11 ms
13,184 KB
testcase_58 AC 9 ms
13,184 KB
testcase_59 AC 5 ms
5,376 KB
testcase_60 AC 10 ms
13,184 KB
testcase_61 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 適当な時刻まで探索して、
// 最後 2 回の到着時刻で周期を決め打ってしまう
// 厳密解の意味では N^3M 解法?(自信なし)

#include<iostream>
using namespace std;
using ll = long long;


bool dp[1000000][100];
int frm[10000];
int to[10000];

ll N, M, T, ans;

int main(){
    cin >> N >> M >> T;
    for(int i=0;i<M;i++){
        cin >> frm[i] >> to[i];
    }
    dp[0][0] = true;
    // 適当なところまで探索する
    int T0 = min(100000ll, 100000000/(N*M));
    for(int t=1;t<=T0;t++){
        for(int e=0;e<M;e++){
            dp[t][to[e]] |= dp[t-1][frm[e]];
        }
    }
    for(int v=0;v<N;v++){
        // last two
        ll t1 = -1;
        ll t2 = -1;
        for (int t=0;t<T0;t++){
            if(dp[t][v]){
                t1 = t2;
                t2 = t;
            }
        }
        if(T < T0){
            ans += (dp[T][v] ? 1 : 0);
        } else{
            if(t1 >= 0){
                ll p = t2 - t1;
                ll n = (T-T0)/p+1;
                ans += (dp[T-n*p][v] ? 1 : 0);
            }
        }
    }
    if(ans==0){
        ans-=1;
    }
    cout << ans << endl;
    return 0;
}
0