| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1338803 | po_rag526 | Shops (NOI24_shops) | C++20 | 243 ms | 30256 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
const int maxn = 5e5 + 5;
int n, m, ans = 0, vis[maxn];
queue <int> q;
vector <ii> adj[maxn];
signed main () {
#define task "code"
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1, u, v, w; i <= m; i++) {
cin >> u >> v >> w;
adj[u].push_back ({v, w});
adj[v].push_back ({u, w});
}
q.push (1);
vis[1] = 1;
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto [v, w] : adj[u]) {
if (vis[v] == 0) {
if (vis[u] == 1) vis[v] = 2;
else vis[v] = 1;
ans = max (ans, w);
q.push (v);
}
}
}
cout << ans << '\n';
for (int i = 1; i <= n; i++) {
if (vis[i] == 1) cout << 'B';
else cout << 'D';
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
