# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
122714 |
2019-06-29T07:23:30 Z |
tjd229 |
None (JOI16_snowy) |
C++14 |
|
24 ms |
2032 KB |
#include "Anyalib.h"
#include <vector>
using namespace std;
int _N;
int u[500], v[500];
int h;
vector<int> eix[500];
//L<-road|hub
int to(int src,int eix) {
if (u[eix] == src) return v[eix];
return u[eix];
}
int dfsa(int x,int from,int s,int *C) {
int len = 0;
for (auto ix : eix[x]) {
int dst = to(x,ix);
if (from == dst) continue;
if (C[ix]) Save(999-dst,1);
int dist = dfsa(dst,x,s+C[ix],C);
if (len < dist) len = dist;
}
++len;
if (x && len > 11) {//hub
int pos = h * 9;
while (s) {
Save(pos++,s&1);
s >>= 1;
}
len = 0;
++h;
}
return len;
}
void InitAnya(int N , int A[] , int B[]) {
_N = N;
for (int i = 0; i < N - 1; ++i) {
u[i] = A[i], v[i] = B[i];
eix[A[i]].push_back(i);
eix[B[i]].push_back(i);
}
}
void Anya(int C[]) {
h = 0;
dfsa(0,-1,0,C);
}
#include "Borislib.h"
#include <vector>
using namespace std;
vector<int> edge[500];
int __N;
int k,hub[500],p[500];
int dfsb(int x,int from) {
int len = 0;
for (auto to : edge[x]) {
if (to == from) continue;
int dist = dfsb(to,x);
p[to] = x;
if (len < dist) len = dist;
}
++len;
if (x && len > 11) hub[x] = ++k,len=0;
return len;
}
void InitBoris(int N , int A[] , int B[]) {
__N = N;
for (int i = 0; i < N - 1; ++i) {
edge[A[i]].push_back(B[i]);
edge[B[i]].push_back(A[i]);
}
dfsb(0, -1);
}
int Boris(int city) {
int ans = 0;
while (city && hub[city] == 0) {
ans += Ask(999-city);
city = p[city];
}
if (hub[city]) {
int pos = hub[city] * 9;
int ac = 0;
for (int i = 0; i < 9; ++i) {
ac += ac;
ac += Ask(--pos);
}
ans += ac;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
768 KB |
Output is correct |
2 |
Correct |
4 ms |
900 KB |
Output is correct |
3 |
Correct |
6 ms |
1200 KB |
Output is correct |
4 |
Correct |
7 ms |
1108 KB |
Output is correct |
5 |
Correct |
9 ms |
1172 KB |
Output is correct |
6 |
Correct |
9 ms |
1412 KB |
Output is correct |
7 |
Correct |
10 ms |
1416 KB |
Output is correct |
8 |
Correct |
9 ms |
1172 KB |
Output is correct |
9 |
Correct |
9 ms |
1420 KB |
Output is correct |
10 |
Correct |
9 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1332 KB |
Output is correct |
2 |
Correct |
10 ms |
1264 KB |
Output is correct |
3 |
Correct |
11 ms |
1432 KB |
Output is correct |
4 |
Correct |
11 ms |
1264 KB |
Output is correct |
5 |
Correct |
11 ms |
1264 KB |
Output is correct |
6 |
Correct |
11 ms |
1520 KB |
Output is correct |
7 |
Correct |
11 ms |
1404 KB |
Output is correct |
8 |
Correct |
10 ms |
1432 KB |
Output is correct |
9 |
Correct |
10 ms |
1264 KB |
Output is correct |
10 |
Correct |
11 ms |
1264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1828 KB |
Output is correct |
2 |
Correct |
21 ms |
1840 KB |
Output is correct |
3 |
Correct |
21 ms |
1876 KB |
Output is correct |
4 |
Correct |
22 ms |
1992 KB |
Output is correct |
5 |
Correct |
21 ms |
1808 KB |
Output is correct |
6 |
Correct |
22 ms |
1872 KB |
Output is correct |
7 |
Correct |
21 ms |
1872 KB |
Output is correct |
8 |
Correct |
21 ms |
1872 KB |
Output is correct |
9 |
Correct |
21 ms |
1776 KB |
Output is correct |
10 |
Correct |
21 ms |
1868 KB |
Output is correct |
11 |
Correct |
21 ms |
1876 KB |
Output is correct |
12 |
Correct |
21 ms |
1776 KB |
Output is correct |
13 |
Correct |
21 ms |
1868 KB |
Output is correct |
14 |
Correct |
21 ms |
1872 KB |
Output is correct |
15 |
Correct |
20 ms |
1872 KB |
Output is correct |
16 |
Correct |
21 ms |
1868 KB |
Output is correct |
17 |
Correct |
21 ms |
1868 KB |
Output is correct |
18 |
Correct |
21 ms |
1836 KB |
Output is correct |
19 |
Correct |
21 ms |
1868 KB |
Output is correct |
20 |
Correct |
21 ms |
2032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1820 KB |
Output is correct |
2 |
Correct |
21 ms |
1824 KB |
Output is correct |
3 |
Correct |
22 ms |
1776 KB |
Output is correct |
4 |
Correct |
21 ms |
1920 KB |
Output is correct |
5 |
Correct |
24 ms |
1860 KB |
Output is correct |
6 |
Correct |
22 ms |
1776 KB |
Output is correct |
7 |
Correct |
22 ms |
1904 KB |
Output is correct |
8 |
Correct |
22 ms |
1908 KB |
Output is correct |
9 |
Correct |
23 ms |
1920 KB |
Output is correct |
10 |
Correct |
22 ms |
1820 KB |
Output is correct |
11 |
Correct |
23 ms |
1824 KB |
Output is correct |
12 |
Correct |
22 ms |
1832 KB |
Output is correct |
13 |
Correct |
23 ms |
1884 KB |
Output is correct |
14 |
Correct |
23 ms |
1920 KB |
Output is correct |
15 |
Correct |
23 ms |
1884 KB |
Output is correct |
16 |
Correct |
19 ms |
1896 KB |
Output is correct |
17 |
Correct |
23 ms |
1952 KB |
Output is correct |
18 |
Correct |
23 ms |
1832 KB |
Output is correct |
19 |
Correct |
22 ms |
1896 KB |
Output is correct |
20 |
Correct |
22 ms |
1824 KB |
Output is correct |
21 |
Correct |
22 ms |
1880 KB |
Output is correct |
22 |
Correct |
22 ms |
1880 KB |
Output is correct |
23 |
Correct |
21 ms |
1832 KB |
Output is correct |
24 |
Correct |
22 ms |
1832 KB |
Output is correct |
25 |
Correct |
21 ms |
1884 KB |
Output is correct |
26 |
Correct |
22 ms |
1832 KB |
Output is correct |
27 |
Correct |
21 ms |
1828 KB |
Output is correct |
28 |
Correct |
21 ms |
1776 KB |
Output is correct |
29 |
Correct |
21 ms |
1820 KB |
Output is correct |
30 |
Correct |
21 ms |
1788 KB |
Output is correct |
31 |
Correct |
22 ms |
1784 KB |
Output is correct |
32 |
Correct |
22 ms |
1776 KB |
Output is correct |
33 |
Correct |
23 ms |
1776 KB |
Output is correct |
34 |
Correct |
22 ms |
1776 KB |
Output is correct |
35 |
Correct |
22 ms |
1824 KB |
Output is correct |
36 |
Correct |
23 ms |
1776 KB |
Output is correct |
37 |
Correct |
22 ms |
1828 KB |
Output is correct |
38 |
Correct |
23 ms |
1776 KB |
Output is correct |
39 |
Correct |
22 ms |
1776 KB |
Output is correct |
40 |
Correct |
21 ms |
1776 KB |
Output is correct |
41 |
Correct |
21 ms |
1828 KB |
Output is correct |
42 |
Correct |
21 ms |
1776 KB |
Output is correct |
43 |
Correct |
22 ms |
1776 KB |
Output is correct |
44 |
Correct |
21 ms |
1776 KB |
Output is correct |
45 |
Correct |
22 ms |
1776 KB |
Output is correct |
46 |
Correct |
22 ms |
1776 KB |
Output is correct |
47 |
Correct |
21 ms |
1784 KB |
Output is correct |
48 |
Correct |
21 ms |
1776 KB |
Output is correct |
49 |
Correct |
21 ms |
1820 KB |
Output is correct |
50 |
Correct |
21 ms |
1776 KB |
Output is correct |