| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1338750 | daotuankhoi | Shops (NOI24_shops) | C++20 | 314 ms | 62052 KiB |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
template <class T> bool ckmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <class T> bool ckmin(T &a, T b) { return a > b ? (a = b, true) : false; }
const int MAXN = 5e5 + 5;
vector<pair<int, int>> g[MAXN];
vector<int> adj[MAXN];
int n, m, nxt[MAXN], col[MAXN];
void dfs(int u, int p) {
for (int v : adj[u]) {
if (v != p) {
col[v] = 3 - col[u];
dfs(v, u);
}
}
}
int main() {
#define NAME "test"
if (fopen(NAME".inp", "r")) {
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v, w; cin >> u >> v >> w;
g[u].emplace_back(w, v);
g[v].emplace_back(w, u);
}
int ans = 0;
for (int i = 1; i <= n; i++) {
sort(g[i].begin(), g[i].end());
nxt[i] = g[i][0].se;
ckmax(ans, g[i][0].fi);
if (nxt[nxt[i]] == i) continue;
adj[i].emplace_back(nxt[i]);
adj[nxt[i]].emplace_back(i);
}
cout << ans << '\n';
for (int i = 1; i <= n; i++) {
if (!col[i]) {
col[i] = 1;
dfs(i, 0);
}
cout << (col[i] == 1 ? 'B' : 'D');
}
return 0;
}
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... | ||||
