結果

問題 No.2431 Viral Hotel
ユーザー Manuel1024Manuel1024
提出日時 2023-08-18 23:58:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,190 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 95,108 KB
実行使用メモリ 21,324 KB
最終ジャッジ日時 2023-08-18 23:58:28
合計ジャッジ時間 8,194 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll MOD = 998244353;

int main(){
    int n, m, k, p; cin >> n >> k >> m >> p;
    vector<vector<int>> G(n);
    for(int i = 0; i < m; i++){
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    vector<int> s(n);
    for(auto &it: s) cin >> it;
    vector<int> x(k);
    for(auto &it: x){
        cin >> it;
        it--;
    }

    vector<map<int, vector<int>>> events(2);
    vector<int> states(n, 0);
    vector<int> cnt(n, 0);

    priority_queue<int, vector<int>, greater<int>> days;
    for(const auto &it: x){
        events[1][s[it]].emplace_back(it);
        //days.emplace(s[it]);
        events[0][p].emplace_back(it);
        //days.emplace(p);
        cnt[it]++;
        states[it] = 1;
    }
    //set<int> past;
    for(int day = 0; day < 110000000; day++){
        // const int day = days.top(); days.pop();
        //if(past.count(day) == 1) continue;
        //past.emplace(day);
        if(events[0].count(day) == 1){
            for(const auto &it: events[0][day]){
                if(states[it] == 3) continue;
                states[it] = 2;
            }
        }
        if(events[1].count(day) == 1){
            for(const auto &it: events[1][day]){
                if(states[it] == 3) continue;
                for(const auto &nex: G[it]){
                    if(2 <= states[nex]) continue;
                    cnt[nex]++;
                    if(cnt[nex] == 1){
                        events[1][day+s[nex]].emplace_back(nex);
                        //days.emplace(day+s[nex]);
                        events[0][day+p].emplace_back(nex);
                        //days.emplace(day+p);
                        states[nex] = 1;
                    }else{
                        states[nex] = 3;
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(states[i] == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}
0