結果

問題 No.1382 Travel in Mitaru city
ユーザー 夜
提出日時 2021-02-08 17:52:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,244 bytes
コンパイル時間 2,394 ms
コンパイル使用メモリ 105,056 KB
実行使用メモリ 5,388 KB
最終ジャッジ日時 2023-09-19 07:41:34
合計ジャッジ時間 6,604 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,388 KB
testcase_01 AC 3 ms
5,320 KB
testcase_02 AC 4 ms
5,328 KB
testcase_03 AC 3 ms
5,164 KB
testcase_04 AC 3 ms
5,388 KB
testcase_05 AC 3 ms
5,304 KB
testcase_06 TLE -
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 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<vector<int>> vec(100010);
bool b[100010] = { false };
int b1[100010];
int p[100010];
int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		b1[i] = p[i];
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vec[a].emplace_back(b);
		vec[b].emplace_back(a);
	}
	priority_queue<pair<int, int>> que;
	que.push(make_pair(p[s], s));
	set<int> st;
	b[s] = true;
	while (!que.empty()) {
		int x = que.top().second;
		int y = que.top().first;
		que.pop();
		for (int i = 0; i < vec[x].size(); i++) {
			if (y > p[vec[x][i]]) {
				st.insert(p[vec[x][i]]);
			}
			if (!b[vec[x][i]]) {
				que.push(make_pair(min(y, p[vec[x][i]]), vec[x][i]));
				b1[vec[x][i]] = min(y, p[vec[x][i]]);
				b[vec[x][i]] = true;
			}
			else if (y > b1[vec[x][i]]) {
				que.push(make_pair(min(y, p[vec[x][i]]), vec[x][i]));
				b1[vec[x][i]] = min(y, p[vec[x][i]]);
			}
			
		}
	}
	cout << st.size() << endl;
}

0