結果

問題 No.1382 Travel in Mitaru city
ユーザー Example0911
提出日時 2021-02-07 21:27:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 200,720 KB
最終ジャッジ日時 2025-01-18 14:28:22
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = (ll)1e9 + 7;


int N;
vector<ll>a;
vector<vector<int>>G;
bool seen[200010];
void dfs(int v) {
	seen[v] = true;
	for (auto nv : G[v]) {
		if (seen[nv])continue;
		dfs(nv);
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	a.resize(N);
	G.resize(N);
	ll M; cin >> M;
	ll S, T; cin >> S >> T; S--; T--;
	for (int i = 0; i < N; i++)cin >> a[i];
	vector<bool>ans(N, true);
	for (int i = 0; i < N; i++) {
		if (a[i] >= a[S])ans[i] = false;
	}
	for (int i = 0; i < M; i++) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(S);
	for (int i = 0; i < N; i++) {
		if (!seen[i])ans[i] = false;
	}
	for (int i = 0; i < N; i++)seen[i] = false;
	dfs(T);
	for (int i = 0; i < N; i++) {
		if (!seen[i])ans[i] = false;
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (ans[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}
0