# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
969154 |
2024-04-24T15:44:05 Z |
abczz |
None (JOI16_snowy) |
C++14 |
|
17 ms |
1996 KB |
#include "Anyalib.h"
#include <iostream>
#include <array>
#include <vector>
#define ll long long
using namespace std;
vector <array<ll, 2> > adj[500];
vector <int> c;
ll n, sz, f, z, q, D[500], cnt[12];
void dfs(ll u, ll p, ll w) {
D[u] = w;
++cnt[w];
for (auto [v, x] : adj[u]) {
if (v != p) dfs(v, u, (w+1)%12);
}
}
void dfs2(ll u, ll p, ll w) {
for (auto [v, x] : adj[u]) {
if (v != p) {
dfs2(v, u, w+c[x]);
if (D[v] != z) Save(sz++, c[x]);
}
}
if (u && D[u] == z) {
for (int i=8; i>=0; --i) {
if ((w & (1<<i))) Save(sz++, 1);
else Save(sz++, 0);
}
}
}
void InitAnya(int N, int A[], int B[]) {
n = N;
for (int i=0; i<N; ++i) {
adj[i].clear();
}
for (int i=0; i<N-1; ++i) {
adj[A[i]].push_back({B[i],i});
adj[B[i]].push_back({A[i],i});
}
dfs(0, -1, 0);
f = 1e18;
for (int i=0; i<12; ++i) {
if (f > cnt[i] && cnt[i]) {
f = cnt[i];
z = i;
}
}
}
void Anya(int C[]) {
c.clear();
for (int i=0; i<n; ++i) c.push_back(C[i]);
sz = 0;
dfs2(0, -1, 0);
}
#include "Borislib.h"
#include <iostream>
#include <array>
#include <vector>
#define ll long long
using namespace std;
vector <array<ll, 2> > adj[500];
vector <int> c;
ll n, sz, f, z, q, D[500], cnt[12];
void dfs(ll u, ll p, ll w) {
D[u] = w;
++cnt[w];
for (auto [v, x] : adj[u]) {
if (v != p) dfs(v, u, (w+1)%12);
}
}
bool query(ll u, ll p) {
bool B = 0, res;
if (u == q) B = 1;
for (auto [v, x] : adj[u]) {
if (v != p) {
res = query(v, u);
if (res) f += Ask(sz);
if (D[v] != z) sz++;
B |= res;
}
}
if (u && D[u] == z) {
for (int i=8; i>=0; --i) {
if (B) f += Ask(sz)*(1<<i);
sz++;
}
return 0;
}
return B;
}
void InitBoris(int N, int A[], int B[]) {
n = N;
for (int i=0; i<N; ++i) {
adj[i].clear();
}
for (int i=0; i<N-1; ++i) {
adj[A[i]].push_back({B[i],i});
adj[B[i]].push_back({A[i],i});
}
dfs(0, -1, 0);
f = 1e18;
for (int i=0; i<12; ++i) {
if (f > cnt[i] && cnt[i]) {
f = cnt[i];
z = i;
}
}
}
int Boris(int city) {
q = city;
f = sz = 0;
query(0, -1);
return f;
}
Compilation message
Anya.cpp: In function 'void dfs(long long int, long long int, long long int)':
Anya.cpp:16:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
16 | for (auto [v, x] : adj[u]) {
| ^
Anya.cpp: In function 'void dfs2(long long int, long long int, long long int)':
Anya.cpp:22:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
22 | for (auto [v, x] : adj[u]) {
| ^
Boris.cpp: In function 'void dfs(long long int, long long int, long long int)':
Boris.cpp:16:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
16 | for (auto [v, x] : adj[u]) {
| ^
Boris.cpp: In function 'bool query(long long int, long long int)':
Boris.cpp:24:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
24 | for (auto [v, x] : adj[u]) {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
792 KB |
Output is correct |
2 |
Correct |
1 ms |
804 KB |
Output is correct |
3 |
Correct |
2 ms |
848 KB |
Output is correct |
4 |
Correct |
3 ms |
1132 KB |
Output is correct |
5 |
Correct |
5 ms |
1204 KB |
Output is correct |
6 |
Correct |
5 ms |
1212 KB |
Output is correct |
7 |
Correct |
5 ms |
1212 KB |
Output is correct |
8 |
Correct |
5 ms |
1284 KB |
Output is correct |
9 |
Correct |
4 ms |
1204 KB |
Output is correct |
10 |
Correct |
5 ms |
1212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1200 KB |
Output is correct |
2 |
Correct |
6 ms |
1248 KB |
Output is correct |
3 |
Correct |
7 ms |
1244 KB |
Output is correct |
4 |
Correct |
6 ms |
1256 KB |
Output is correct |
5 |
Correct |
6 ms |
1252 KB |
Output is correct |
6 |
Correct |
5 ms |
1256 KB |
Output is correct |
7 |
Correct |
6 ms |
1248 KB |
Output is correct |
8 |
Correct |
5 ms |
1248 KB |
Output is correct |
9 |
Correct |
6 ms |
1248 KB |
Output is correct |
10 |
Correct |
5 ms |
1248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1216 KB |
Output is correct |
2 |
Correct |
13 ms |
1728 KB |
Output is correct |
3 |
Correct |
14 ms |
1716 KB |
Output is correct |
4 |
Correct |
13 ms |
1728 KB |
Output is correct |
5 |
Correct |
12 ms |
1968 KB |
Output is correct |
6 |
Correct |
13 ms |
1732 KB |
Output is correct |
7 |
Correct |
14 ms |
1732 KB |
Output is correct |
8 |
Correct |
14 ms |
1712 KB |
Output is correct |
9 |
Correct |
15 ms |
1952 KB |
Output is correct |
10 |
Correct |
13 ms |
1732 KB |
Output is correct |
11 |
Correct |
16 ms |
1720 KB |
Output is correct |
12 |
Correct |
14 ms |
1728 KB |
Output is correct |
13 |
Correct |
13 ms |
1724 KB |
Output is correct |
14 |
Correct |
13 ms |
1728 KB |
Output is correct |
15 |
Correct |
15 ms |
1732 KB |
Output is correct |
16 |
Correct |
17 ms |
1724 KB |
Output is correct |
17 |
Correct |
14 ms |
1724 KB |
Output is correct |
18 |
Correct |
13 ms |
1752 KB |
Output is correct |
19 |
Correct |
15 ms |
1704 KB |
Output is correct |
20 |
Correct |
13 ms |
1732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1216 KB |
Output is correct |
2 |
Correct |
13 ms |
1716 KB |
Output is correct |
3 |
Correct |
12 ms |
1984 KB |
Output is correct |
4 |
Correct |
13 ms |
1716 KB |
Output is correct |
5 |
Correct |
14 ms |
1724 KB |
Output is correct |
6 |
Correct |
11 ms |
1728 KB |
Output is correct |
7 |
Correct |
14 ms |
1724 KB |
Output is correct |
8 |
Correct |
11 ms |
1728 KB |
Output is correct |
9 |
Correct |
14 ms |
1724 KB |
Output is correct |
10 |
Correct |
13 ms |
1720 KB |
Output is correct |
11 |
Correct |
14 ms |
1704 KB |
Output is correct |
12 |
Correct |
11 ms |
1708 KB |
Output is correct |
13 |
Correct |
14 ms |
1728 KB |
Output is correct |
14 |
Correct |
14 ms |
1724 KB |
Output is correct |
15 |
Correct |
15 ms |
1724 KB |
Output is correct |
16 |
Correct |
12 ms |
1840 KB |
Output is correct |
17 |
Correct |
14 ms |
1924 KB |
Output is correct |
18 |
Correct |
16 ms |
1724 KB |
Output is correct |
19 |
Correct |
16 ms |
1740 KB |
Output is correct |
20 |
Correct |
13 ms |
1776 KB |
Output is correct |
21 |
Correct |
13 ms |
1744 KB |
Output is correct |
22 |
Correct |
13 ms |
1740 KB |
Output is correct |
23 |
Correct |
13 ms |
1740 KB |
Output is correct |
24 |
Correct |
13 ms |
1744 KB |
Output is correct |
25 |
Correct |
13 ms |
1748 KB |
Output is correct |
26 |
Correct |
13 ms |
1740 KB |
Output is correct |
27 |
Correct |
13 ms |
1744 KB |
Output is correct |
28 |
Correct |
13 ms |
1728 KB |
Output is correct |
29 |
Correct |
15 ms |
1996 KB |
Output is correct |
30 |
Correct |
15 ms |
1724 KB |
Output is correct |
31 |
Correct |
13 ms |
1724 KB |
Output is correct |
32 |
Correct |
12 ms |
1788 KB |
Output is correct |
33 |
Correct |
14 ms |
1716 KB |
Output is correct |
34 |
Correct |
11 ms |
1728 KB |
Output is correct |
35 |
Correct |
11 ms |
1848 KB |
Output is correct |
36 |
Correct |
14 ms |
1732 KB |
Output is correct |
37 |
Correct |
11 ms |
1724 KB |
Output is correct |
38 |
Correct |
14 ms |
1740 KB |
Output is correct |
39 |
Correct |
11 ms |
1720 KB |
Output is correct |
40 |
Correct |
11 ms |
1720 KB |
Output is correct |
41 |
Correct |
11 ms |
1720 KB |
Output is correct |
42 |
Correct |
11 ms |
1720 KB |
Output is correct |
43 |
Correct |
11 ms |
1728 KB |
Output is correct |
44 |
Correct |
12 ms |
1728 KB |
Output is correct |
45 |
Correct |
11 ms |
1720 KB |
Output is correct |
46 |
Correct |
12 ms |
1716 KB |
Output is correct |
47 |
Correct |
11 ms |
1720 KB |
Output is correct |
48 |
Correct |
11 ms |
1724 KB |
Output is correct |
49 |
Correct |
11 ms |
1716 KB |
Output is correct |
50 |
Correct |
13 ms |
1712 KB |
Output is correct |