結果
問題 |
No.92 逃走経路
|
ユーザー |
|
提出日時 | 2025-06-30 06:05:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,081 bytes |
コンパイル時間 | 2,120 ms |
コンパイル使用メモリ | 203,424 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-30 06:06:01 |
合計ジャッジ時間 | 4,260 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 RE * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<typename T> istream &operator>>(istream &is,vector<T> &a){ for(auto &v : a) cin >> v; return is; } template<typename T> ostream &operator<<(ostream &os,const vector<T> &a){ if(a.size() == 0) return os; cout << a.at(0); for(int i=1; i<a.size(); i++) cout << " " << a.at(i); cout << "\n"; return os; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M,K; cin >> N >> M >> K; vector<vector<pair<int,int>>> Cs(1000); while(M--){ int a,b,c; cin >> a >> b >> c; a--,b--,c--; Cs.at(c).push_back({a,b}); } vector<bool> OK(N,true); while(K--){ int d; cin >> d; d--; vector<bool> next(N); for(auto [a,b] : Cs.at(d)){ if(OK.at(b)) next.at(a) = true; if(OK.at(a)) next.at(b) = true; } swap(OK,next); } int ok = 0; for(int i=0; i<N; i++) ok += OK.at(i); cout << ok << "\n"; for(int i=0; i<N; i++) if(OK.at(i)) cout << i+1 << (ok==1?"\n":" "),ok--; }