結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
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,e;
  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;
    e=0;
    for(int j=0; j<v.size(); ++j){
      int& a=get<0>(v[j]);
      int& b=get<1>(v[j]);
      int& c=get<2>(v[j]);
      if(c==d) e++;
    }
    if(e==1){
      for(int j=0; j<v.size(); ++j){
        int& a=get<0>(v[j]);
        int& b=get<1>(v[j]);
        int& c=get<2>(v[j]);
        if(c==d){
          if(p[a-1]==1 && p[b-1]==1){
            //
          } else if(p[a-1]==1 && p[b-1]==0){
            for(int k=0; k<n; ++k){
              p[k]=0;
            }
            p[b-1]=1;
          } else if(p[a-1]==0 && p[b-1]==1){
            for(int k=0; k<n; ++k){
              p[k]=0;
            }
            p[a-1]=1;
          } else if(p[a-1]==0 && p[b-1]==0){
            p[a-1]=1;
            p[b-1]=1;
          }
        }
      }
    } else if(e>1){
      for(int j=0; j<v.size(); ++j){
        int& a=get<0>(v[j]);
        int& b=get<1>(v[j]);
        int& c=get<2>(v[j]);
        if(c==d){
          if(p[a-1]==1 && p[b-1]==1){
            //
          } else if(p[a-1]==1 && p[b-1]==0){
            p[b-1]=1;
          } else if(p[a-1]==0 && p[b-1]==1){
            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