結果

問題 No.1340 おーじ君をさがせ
ユーザー kappybarkappybar
提出日時 2021-01-15 23:18:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,533 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 167,068 KB
実行使用メモリ 6,288 KB
最終ジャッジ日時 2023-08-18 16:45:32
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 19 ms
5,272 KB
testcase_12 AC 5 ms
4,600 KB
testcase_13 AC 16 ms
4,376 KB
testcase_14 AC 40 ms
5,288 KB
testcase_15 AC 33 ms
4,384 KB
testcase_16 AC 4 ms
4,532 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 24 ms
4,380 KB
testcase_19 AC 3 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 5 ms
5,208 KB
testcase_22 AC 6 ms
5,808 KB
testcase_23 AC 5 ms
5,072 KB
testcase_24 AC 6 ms
6,140 KB
testcase_25 AC 5 ms
4,384 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 3 ms
4,384 KB
testcase_28 AC 5 ms
4,384 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 6 ms
5,148 KB
testcase_31 AC 8 ms
6,216 KB
testcase_32 AC 61 ms
6,200 KB
testcase_33 AC 56 ms
6,236 KB
testcase_34 AC 74 ms
6,156 KB
testcase_35 AC 76 ms
6,164 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 4 ms
4,380 KB
testcase_38 AC 51 ms
4,380 KB
testcase_39 AC 19 ms
6,288 KB
testcase_40 AC 19 ms
6,240 KB
testcase_41 AC 20 ms
6,188 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 47 ms
6,136 KB
testcase_47 AC 49 ms
6,288 KB
testcase_48 AC 51 ms
6,192 KB
testcase_49 AC 16 ms
6,192 KB
testcase_50 AC 16 ms
6,192 KB
testcase_51 AC 15 ms
6,232 KB
testcase_52 AC 59 ms
6,176 KB
testcase_53 AC 59 ms
6,212 KB
testcase_54 AC 58 ms
6,244 KB
testcase_55 AC 114 ms
6,288 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 52 ms
4,380 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 53 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int G[105][105];
int doubling[66][105][105];// 1<<i回でj->kに行ける

int main(){
    int n,m;
    ll t;
    cin >> n >> m >> t;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        doubling[0][a][b] = 1;
    }
    for(int i=0;i<65;i++){
        rep(j,n){
            rep(k,n){
                // doubling[i+1][j][k]
                rep(l,n){
                    if(doubling[i][j][l] == 1 && doubling[i][l][k] == 1){
                        doubling[i+1][j][k] = 1;
                        break;
                    }
                }
            }
        }
    }
    vector<int> been(n,0);
    been[0] = 1;
    int c = 0;
    while(t > 0){
        if(t&1){
            vector<int> nxt(n,0);
            rep(i,n){
                if(been[i]==1){
                    rep(j,n){
                        if(doubling[c][i][j] == 1){
                            nxt[j] = 1;
                        }
                    }
                }
            }
            swap(been,nxt);
        }
        t >>= 1;
        ++c;
    }
    int sum = 0;
    rep(i,n) sum += (been[i]==1);
    cout << sum << endl;
    return 0;
}
0