結果

問題 No.92 逃走経路
ユーザー imulanimulan
提出日時 2016-02-06 18:28:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,350 bytes
コンパイル時間 1,428 ms
コンパイル使用メモリ 166,476 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 19:28:46
合計ジャッジ時間 2,305 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:66:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   66 |   printf("%d\n", ans.size());
      |           ~^     ~~~~~~~~~~
      |            |             |
      |            int           std::vector<int>::size_type {aka long unsigned int}
      |           %ld

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i,j,x;

  int n,m,k;
  cin >>n >>m >>k;

  //コスト、行き先で保存
  vector< pair<int,int> > v[101];

  rep(i,m){
    int a,b,c;
    cin >>a >>b >>c;
    v[a].pb(mp(c,b));
    v[b].pb(mp(c,a));
  }

  vector<int> d(k);
  rep(i,k) cin >>d[i];

  //現段階で居場所としてありえる場所
  bool valid[101];
  rep(i,n+1) valid[i]=true;

  rep(i,k){
    bool tmp[101];
    rep(j,n+1) tmp[j]=false;

    //d[i]にコストが一致する道があるかそれぞれ探す
    for(j=1; j<=n; ++j){
      if(!valid[j]) continue;

      for(x=0; x<v[j].size(); ++x){
        if(v[j][x].fi==d[i]){
          tmp[v[j][x].sc]=true;
        }
      }
    }

    rep(j,n+1) valid[j]=tmp[j];

    /*
    printf("turn %d:",i);
    for(j=1; j<=n; ++j){
      if(valid[j]) printf(" %d", j);
    }
    printf("\n");
    */
  }

  std::vector<int> ans;
  for(i=1; i<=n; ++i){
    if(valid[i]) ans.pb(i);
  }

  printf("%d\n", ans.size());
  rep(i,ans.size()){
    if(i) printf(" ");
    printf("%d", ans[i]);
  }
  printf("\n");
  return 0;
}
0