# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
288021 |
2020-09-01T07:57:20 Z |
Alexa2001 |
None (JOI16_snowy) |
C++17 |
|
17 ms |
1884 KB |
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
static int getL;
namespace
{
const int Nmax = 1005;
vector<int> v[Nmax];
int n, w[Nmax], t[Nmax];
bool special[Nmax];
pair<int,int> edge[Nmax];
void dfs0(int node, int dad = -1)
{
w[node] = 0;
t[node] = dad;
for(auto it : v[node])
if(it != dad)
{
dfs0(it, node);
w[node] = max(w[it], w[node]);
}
if(w[node] == 9)
{
w[node] = 0;
special[node] = 1;
}
else ++w[node];
}
void dfs(int node, int dad, int C[])
{
for(auto it : v[node])
if(it != dad)
{
dfs(it, node, C);
w[node] += w[it];
}
}
};
void InitAnya(int N , int A[] , int B[])
{
n = N;
int i;
for(i=0; i<n-1; ++i)
{
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
edge[i] = {A[i], B[i]};
}
dfs0(0);
for(i=0; i<n-1; ++i)
if(t[edge[i].first] == edge[i].second) swap(edge[i].first, edge[i].second);
}
void Anya(int C[])
{
int i, j;
for(i=0; i<n; ++i) w[i] = 0;
for(i=0; i<n-1; ++i)
w[edge[i].second] += C[i];
for(i=1; i<n; ++i)
Save(i, w[i]);
dfs(0, -1, C);
int nr = n;
for(i=0; i<n; ++i)
if(special[i])
for(j=8; j>=0; --j)
{
Save(nr, (w[i] >> j) & 1);
++nr;
}
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
const int Nmax = 1005;
int n;
vector<int> v[Nmax];
int w[Nmax], where[Nmax], t[Nmax];
bool special[Nmax];
void dfs0(int node, int dad = -1)
{
w[node] = 0;
t[node] = dad;
for(auto it : v[node])
if(it != dad)
{
dfs0(it, node);
w[node] = max(w[it], w[node]);
}
if(w[node] == 9)
{
w[node] = 0;
special[node] = 1;
}
else ++w[node];
}
};
void InitBoris(int N , int A[] , int B[])
{
n = N;
int i;
for(i=0; i<n-1; ++i)
{
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
dfs0(0);
int nr = n;
for(i=0; i<n; ++i)
if(special[i])
{
where[i] = nr;
nr += 9;
}
}
int Boris(int x)
{
if(x == 0) return 0;
if(special[x])
{
int ans = 0, i;
for(i = where[x]; i < where[x] + 9; ++i)
ans = 2 * ans + Ask(i);
return ans;
}
return Ask(x) + Boris(t[x]);
}
Compilation message
Anya.cpp:6:12: warning: 'getL' defined but not used [-Wunused-variable]
6 | static int getL;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
992 KB |
Output is correct |
2 |
Correct |
3 ms |
980 KB |
Output is correct |
3 |
Correct |
4 ms |
1220 KB |
Output is correct |
4 |
Incorrect |
3 ms |
1024 KB |
Wrong Answer [4] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1376 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
1884 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
1856 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |