結果

問題 No.92 逃走経路
ユーザー itezpaceitezpace
提出日時 2016-08-01 08:03:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,169 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 69,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 13:27:27
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
int main(){
  int n,m,k,a,b,c,d;
  cin>>n>>m>>k;
  vector<tuple<int,int,int>> v;
  for(int i=0; i<m; ++i){
    cin>>a>>b>>c;
    tuple<int,int,int> t;
    t=make_tuple(a,b,c);
    v.push_back(t);
  }
  vector<int> p;
  for(int i=0; i<n; ++i){
    p.push_back(0);
  }
  for(int i=0; i<k; ++i){
    cin>>d;
    for(int i=0; i<v.size(); ++i){
      int& a=get<0>(v[i]);
      int& b=get<1>(v[i]);
      int& c=get<2>(v[i]);
      if(c==d){
        if(p[a-1]==1 && p[b-1]==1){
          //
        } else if(p[a-1]==1 && p[b-1]==0){
          for(int j=0; j<n; ++j){
            p[j]=0;
          }
          p[b-1]=1;
        } else if(p[a-1]==0 && p[b-1]==1){
          for(int j=0; j<n; ++j){
            p[j]=0;
          }
          p[a-1]=1;
        } else if(p[a-1]==0 && p[b-1]==0){
          p[a-1]=1;
          p[b-1]=1;
        }
      }
    }
  }
  int x;
  x=0;
  vector<int> y;
  for(int i=0; i<n; ++i){
    if(p[i]==1){
      x++;
      y.push_back(i+1);
    }
  }
  cout<<x<<endl;
  cout<<y[0];
  for(int i=1; i<y.size(); ++i){
    cout<<" "<<y[i];
  }
  cout<<endl;
  return 0;
}
0