結果

問題 No.1340 おーじ君をさがせ
ユーザー maspymaspy
提出日時 2020-09-26 17:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,034 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 70,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 02:32:10
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 34 ms
5,376 KB
testcase_22 AC 42 ms
5,376 KB
testcase_23 AC 36 ms
5,376 KB
testcase_24 AC 28 ms
5,376 KB
testcase_25 AC 11 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 13 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 38 ms
5,376 KB
testcase_31 AC 104 ms
5,376 KB
testcase_32 AC 102 ms
5,376 KB
testcase_33 AC 101 ms
5,376 KB
testcase_34 AC 98 ms
5,376 KB
testcase_35 AC 102 ms
5,376 KB
testcase_36 WA -
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 198 ms
5,376 KB
testcase_39 AC 194 ms
5,376 KB
testcase_40 AC 196 ms
5,376 KB
testcase_41 AC 197 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 28 ms
5,376 KB
testcase_47 AC 28 ms
5,376 KB
testcase_48 AC 28 ms
5,376 KB
testcase_49 AC 4 ms
5,376 KB
testcase_50 AC 5 ms
5,376 KB
testcase_51 AC 4 ms
5,376 KB
testcase_52 WA -
testcase_53 AC 5 ms
5,376 KB
testcase_54 AC 5 ms
5,376 KB
testcase_55 AC 22 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 1 ms
5,376 KB
testcase_59 AC 5 ms
5,376 KB
testcase_60 AC 2 ms
5,376 KB
testcase_61 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 間違っていたので修正
// O(N^2M) 解法

#include<iostream>
#include<algorithm>
#include<vector>
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++){
        int from[i], b;
        cin >> frm[i] >> to[i];
    }
    dp[0][0] = true;
    int T_max = N * N + 10 * N;
    for(int t=1;t<=T_max;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<T_max;t++){
            if(dp[t][v]){
                t1 = t2;
                t2 = t;
            }
        }
        if(T < T_max){
            ans += (dp[T][v] ? 1 : 0);
        } else{
            if(t1 > N){
                ll p = t2 - t1;
                ans += ((T-t2)%p==0 ? 1 : 0);
            }
        }
    }
    if(ans==0){
        ans-=1;
    }
    cout << ans << endl;
    return 0;
}
0