結果

問題 No.92 逃走経路
ユーザー ytftytft
提出日時 2021-03-10 13:53:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 176,452 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 09:02:20
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
6,816 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 14 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename type1,typename type2>
type2 vector_reduce(vector<type1>& v,function<type2(type2,type1)> fn,type2 initial){
    int N=v.size();
    type2 ans=initial;
    for(int i=0;i<N;i++){
        ans=fn(ans,v[i]);
    }
    return ans;
}
int main(){
    int N,M,K;
    cin>>N>>M>>K;
    vector<vector<int>> road(0,vector<int>(3));
    vector<bool> possible(N+1,true);
    vector<bool> next(N+1);
    vector<bool> mask(N+1);
    possible[0]=false;
    int a,b,c,d;
    for(int i=0;i<M;i++){
        cin>>a>>b>>c;
        road.push_back({a,b,c});
        road.push_back({b,a,c});
    }
    for(int i=0;i<K;i++){
        cin>>d;
        next=mask;
        for(int j=0;j<2*M;j++){
            if(possible[road[j][0]] && d==road[j][2]){
                next[road[j][1]]=true;
            }
        }
        possible=next;
    }
    function<int(int,bool)> fn=[](int p,bool a){return p+(a?1:0);};
    cout<<vector_reduce(possible,fn,0)<<endl;
    for(int i=0;i<N;i++){
        if(possible[i]){
            cout<<i<<" ";
        }
    }
    
}
0