結果

問題 No.92 逃走経路
ユーザー kpinkcatkpinkcat
提出日時 2023-10-17 12:51:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,497 bytes
コンパイル時間 1,472 ms
コンパイル使用メモリ 124,980 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 12:51:51
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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);
    set<int> now, can;
    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.insert(list[j][1]);
                    can.insert(list[j][2]);
                }
            }
        }
    }
    sort(list.begin(), list.end());
    for (int i = 0; i < m; i++) list1[i] = list[i][0]; 
    for (int i = 1; i < k; i++){
        int idx = -1;
        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.find(list[j][1]) != can.end()) now.insert(list[j][2]);
                if (can.find(list[j][2]) != can.end()) now.insert(list[j][1]);
            } else break;
        }
        can = now;
    }
    cout << can.size() << endl;
    string delim = "";
    for (auto x : can){
        cout << delim << x;
        delim = " ";
    }
    cout << endl;
}
0