# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
49683 |
2018-06-02T07:15:18 Z |
강태규(#1275, imeimi2000) |
None (JOI16_snowy) |
C++11 |
|
13 ms |
2352 KB |
#include "Anyalib.h"
#include <algorithm>
#include <vector>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static void dfs1(int x, int p, pii cl) {
if (cl.first > t) {
close[x] = pii(0, x);
cl = pii(0, x);
}
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
static int dist[MAXN];
static int par[MAXN];
static void dfs2(int x, int p, int d, int C[]) {
dist[x] = d;
for (pii i : edge[x]) {
if (i.second == p) continue;
par[i.second] = C[i.first];
dfs2(i.second, x, d + C[i.first], C);
}
}
void InitAnya(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
void Anya(int C[]) {
dfs2(0, -1, 0, C);
for (int i = 0; i < n; ++i) {
Save(s[i], par[i]);
for (int j = s[i] + 1; j <= e[i]; ++j) {
Save(j, dist[i] & 1);
dist[i] >>= 1;
}
}
}
#include "Borislib.h"
#include <algorithm>
#include <vector>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static int par[MAXN];
static int dep[MAXN];
static void dfs1(int x, int p, pii cl) {
par[x] = p;
if (cl.first > t) {
close[x] = pii(0, x);
cl = pii(0, x);
}
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dep[i.second] = dep[x] + 1;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
void InitBoris(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
int Boris(int x) {
int y = close[x].second;
int ret = 0;
for (int i = e[y]; i > s[y]; --i) {
ret <<= 1;
ret += Ask(i);
}
while (dep[x] < dep[y]) {
ret -= Ask(s[y]);
y = par[y];
}
while (dep[x] > dep[y]) {
ret += Ask(s[x]);
x = par[x];
}
while (x != y) {
ret += Ask(s[x]) - Ask(s[y]);
x = par[x];
y = par[y];
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
756 KB |
Output is correct |
2 |
Correct |
4 ms |
1008 KB |
Output is correct |
3 |
Correct |
8 ms |
1332 KB |
Output is correct |
4 |
Correct |
9 ms |
1612 KB |
Output is correct |
5 |
Correct |
12 ms |
1984 KB |
Output is correct |
6 |
Correct |
12 ms |
2052 KB |
Output is correct |
7 |
Correct |
10 ms |
2088 KB |
Output is correct |
8 |
Correct |
13 ms |
2312 KB |
Output is correct |
9 |
Incorrect |
8 ms |
2312 KB |
Wrong Answer [6] |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2312 KB |
Output is correct |
2 |
Incorrect |
10 ms |
2352 KB |
Wrong Answer [6] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2352 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2352 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |