# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
733432 |
2023-04-30T17:25:00 Z |
happypotato |
None (JOI16_snowy) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
const int mxN = 1000;
int n;
vector<pii> edge;
vector<pair<int, pii>> adj[mxN]; // {node, {0/1, idx}}
int ans[mxN];
vector<int> key;
map<int, int> mp;
pii par[mxN];
int dfs(int u = 0, int pp = -1, int cur = 0) {
ans[u] = cur;
int res = 0;
for (pair<int, pii> &v : adj[u]) {
if (v.ff == pp) continue;
par[v.ff] = {u, v.ss.ss};
res = max(res, dfs(v.ff, u, cur + v.ss.ff) + 1);
}
if (res >= 10) {
key.pb(u);
res -= 10;
}
return res;
}
void InitAnya(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n - 1; i++) {
edge.pb({A[i], B[i]});
}
}
void Anya(int C[]) {
for (int i = 0; i < n; i++) {
adj[i].clear();
}
key.clear();
for (int i = 0; i < n - 1; i++) {
adj[edge[i].ff].pb({edge[i].ss, {C[i], i}});
adj[edge[i].ss].pb({edge[i].ff, {C[i], i}});
}
dfs();
for (int i = 0; i < n - 1; i++) {
Save(500 + i, C[i]);
}
assert(key.size() <= 50);
for (int i = 0; i < (int)(key.size()); i++) {
for (int j = 0; j < 10; j++) {
Save(i * 10 + j, bool(ans[key[i]] & (1 << j)));
}
}
}
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
const int mxN = 1000;
int n;
vector<pii> edge;
vector<pair<int, pii>> adj[mxN]; // {node, {0/1, idx}}
int ans[mxN];
vector<int> key;
map<int, int> mp;
pii par[mxN];
int dfs(int u = 0, int pp = -1, int cur = 0) {
ans[u] = cur;
int res = 0;
for (pair<int, pii> &v : adj[u]) {
if (v.ff == pp) continue;
par[v.ff] = {u, v.ss.ss};
res = max(res, dfs(v.ff, u, cur + v.ss.ff) + 1);
}
if (res >= 10) {
key.pb(u);
res -= 10;
}
return res;
}
void InitBoris(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n - 1; i++) {
adj[A[i]].pb({B[i], {0, i}});
adj[B[i]].pb({A[i], {0, i}});
}
dfs();
mp[0] = -1;
for (int i = 0; i < (int)(key.size()); i++) {
mp[key[i]] = i;
}
}
int Boris(int city) {
int ans = 0;
while (mp.find(city) == mp.end()) {
ans += Ask(500 + par[city].ss);
city = par[city].ff;
}
if (city) {
for (int i = 0; i < 10; i++) {
ans += (Ask(mp[city] * 10 + i) << i);
}
}
return ans;
}
Compilation message
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:50:3: error: 'Save' was not declared in this scope
50 | Save(500 + i, C[i]);
| ^~~~
Anya.cpp:55:4: error: 'Save' was not declared in this scope
55 | Save(i * 10 + j, bool(ans[key[i]] & (1 << j)));
| ^~~~
Boris.cpp: In function 'int Boris(int)':
Boris.cpp:48:10: error: 'Ask' was not declared in this scope
48 | ans += Ask(500 + par[city].ss);
| ^~~
Boris.cpp:53:12: error: 'Ask' was not declared in this scope
53 | ans += (Ask(mp[city] * 10 + i) << i);
| ^~~