結果

問題 No.92 逃走経路
コンテスト
ユーザー C
提出日時 2026-10-06 02:32:15
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 5,000 ms
+ 484µs
コード長 1,331 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,327 ms
コンパイル使用メモリ 389,964 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-10-13 13:29:56
合計ジャッジ時間 6,930 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using pll=pair<ll,ll>;

// using mint=modint;

// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;

struct Edge{
    ll a,b,c;
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    ll N,M,K;
    cin>>N>>M>>K;
    vector<Edge>e(M);
    rep(i,0,M){
        cin>>e[i].a>>e[i].b>>e[i].c;
        e[i].a--,e[i].b--;
    }
    vector<bool>possible(N,true);
    rep(i,0,K){
        vector<bool>nxt(N,false);
        ll d;
        cin>>d;
        for(auto x:e){
            ll u=x.a,v=x.b,c=x.c;
            if(c!=d)continue;
            if(possible[u])nxt[v]=true;
            if(possible[v])nxt[u]=true;
        }
        swap(nxt,possible);
    }
    vll ans;
    rep(i,0,N){
        if(possible[i])ans.push_back(i+1);
    }
    ll m=sz(ans);
    cout<<m<<'\n';
    rep(i,0,m){
        if(i)cout<<' ';
        cout<<ans[i];
    }
    cout<<'\n';

}
0