結果

問題 No.92 逃走経路
ユーザー kpinkcatkpinkcat
提出日時 2023-10-17 17:43:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,814 bytes
コンパイル時間 2,444 ms
コンパイル使用メモリ 213,076 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-17 17:44:03
合計ジャッジ時間 4,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    int n , m, k;
    cin >> n >> m >> k;
    vector<vector<int>> list(m, vector<int>(3));
    vector<int> fee(k), list1(m);
    vector<int> can(n);
    for (int i = 0; i < m; i++){
        cin >> list[i][1] >> list[i][2] >> list[i][0];
    }
    for (int i = 0; i < k; i++){
        cin >> fee[i];
        if (i == 0) {
            for (int j = 0; j < m; j++){
                if (fee[0] == list[j][0]){
                    can[list[j][1]]++;
                    can[list[j][2]]++;
                }
            }
        }
    }

    sort(list.begin(), list.end(), [](const vector<int> &alpha,const vector<int> &beta){return alpha[0] < beta[0];});
    for (int i = 0; i < m; i++) list1[i] = list[i][0]; 
    for (int i = 1; i < k; i++){
        int idx = -1;
        vector<int> now(n);
        for (int r = 0; r < n; r++) {
            if (can[r]) {
                auto itr = lower_bound(list1.begin(), list1.end(), fee[i]);
                if (itr != list1.end()) idx = distance(list1.begin(), itr);
                for (int j = idx; j < m; j++){
                    if (list1[j] == fee[i]){
                        if (can[list[j][1]]) now[list[j][2]] = 1;
                        if (can[list[j][2]]) now[list[j][1]] = 1;
                    } else break;
                }
            }
        }
        swap(can, now);
    }
    cout << accumulate(can.begin(), can.end(), 0) << endl;
    string delim = "";
    for (int i = 0; i < n; i++){
        if (can[i]){
            cout << delim << i;
            delim = " ";
        }
    }
    cout << endl;
}
0