Linux tsuru-no-tsurugi 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
Apache/2.4.52 (Ubuntu)
Server IP : 192.168.0.18 & Your IP : 216.73.217.105
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
submit2 /
114886 /
Delete
Unzip
Name
Size
Permission
Date
Action
a.cpp
1.44
KB
-rwxr-x---
2024-08-28 22:35
cerror.txt
0
B
-rwxr-x---
2024-08-28 22:35
error.txt
0
B
-rwxr-x---
2024-08-28 22:35
submit_info.txt
197
B
-rwxr-x---
2024-08-28 22:35
Save
Rename
#include <queue> #include <vector> #include <iostream> #include <algorithm> #include <functional> signed main() { int n, m, x, p; std::cin >> n >> m >> x >> p; std::vector<int> b(n); std::vector<int> t(m); for (int &a : b) std::cin >> a; for (int &a : t) std::cin >> a; std::vector<bool> has(m); std::sort(b.begin(), b.end()); std::vector<std::pair<int, int>> ki(m); for (int i = 0; i < m; i++) { ki[i].first = t[i]; ki[i].second = i; } sort(ki.begin(), ki.end()); int it = 0; for (int mise : b) { while (it < m && ki[it].first <= mise + p) { if (mise - p <= ki[it].first) has[ki[it].second] = true; it++; } } std::vector<std::vector<int>> edge(m); for (int i = 0, u, v; i < x; i++) { std::cin >> u >> v; edge[u].push_back(v); edge[v].push_back(u); } std::vector<bool> vis(m); std::queue<int> bfs; int ans = 0; for (int i = 0; i < m; i++) if (has[i] && !vis[i]) { bfs.push(i); while (!bfs.empty()) { int u = bfs.front(); vis[u] = true; bfs.pop(); for (int v : edge[u]) if (!vis[v]) bfs.push(v); } ans++; } std::cout << ans << '\n'; }