結果

問題 No.92 逃走経路
ユーザー しらっ亭しらっ亭
提出日時 2016-03-15 04:08:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 1,484 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 176,024 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 13:17:20
合計ジャッジ時間 2,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 17 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 8 ms
6,676 KB
testcase_10 AC 91 ms
6,676 KB
testcase_11 AC 80 ms
6,676 KB
testcase_12 AC 64 ms
6,676 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 13 ms
6,676 KB
testcase_15 AC 17 ms
6,676 KB
testcase_16 AC 13 ms
6,676 KB
testcase_17 AC 12 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 5 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void Main()’:
main.cpp:44:3: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   44 |   auto_ptr<set<int>> cur(new set<int>());
      |   ^~~~~~~~
In file included from /usr/include/c++/11/bits/locale_conv.h:41,
                 from /usr/include/c++/11/locale:43,
                 from /usr/include/c++/11/iomanip:43,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,
                 from main.cpp:1:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~
main.cpp:45:3: warning: ‘template<class> class std::auto_ptr’ is deprecated: use 'std::unique_ptr' instead [-Wdeprecated-declarations]
   45 |   auto_ptr<set<int>> nex(new set<int>());
      |   ^~~~~~~~
In file included from /usr/include/c++/11/bits/locale_conv.h:41,
                 from /usr/include/c++/11/locale:43,
                 from /usr/include/c++/11/iomanip:43,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,
                 from main.cpp:1:
/usr/include/c++/11/bits/unique_ptr.h:57:28: note: declared here
   57 |   template<typename> class auto_ptr;
      |                            ^~~~~~~~

ソースコード

diff #

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FORR(x,arr) for(auto&& x:arr)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
typedef long long ll;
// -------------------------------------

int n, m, k;
typedef pair<int, int> II;
map<int, vector<II>> E;
int d[1000];

template<typename T> void out(T& s) {
  int i = 0;
  int size = s.size();
  for (auto&&c : s) {
    printf(i + 1 < size ? "%d " : "%d\n", c);
    i++;
  }
}

void Main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  REP(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    E[c].push_back({a, b});
  }
  REP(i, k) cin >> d[i];

  auto_ptr<set<int>> cur(new set<int>());
  auto_ptr<set<int>> nex(new set<int>());
  FOR(i, 1, n+1) cur->insert(i);

  REP(i, k) {
    nex->clear();
    FORR(ab, E[d[i]]) {
      int a = ab.first;
      int b = ab.second;
      if (cur->count(a)) nex->insert(b);
      if (cur->count(b)) nex->insert(a);
    }
    swap(cur, nex);
  }

  cout << SZ(*cur) << endl;
  out(*cur);
}

int main() {Main(); return 0;}
0