# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
158255 |
2019-10-15T19:29:15 Z |
TadijaSebez |
None (JOI16_snowy) |
C++11 |
|
27 ms |
2044 KB |
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
namespace _Anya
{
const int M=505;
vector<pair<int,int>> E[M];
int nod[M],dep[M],n;
int mark[M],csz;
vector<int> marked;
int DFS(int u, int p)
{
int mx=0;
for(auto e:E[u]) if(e.first!=p)
{
nod[e.second]=e.first;
int now=DFS(e.first,u);
mx=max(mx,now);
}
mx++;
if(mx>=11)
{
mx=0;
mark[u]=++csz;
marked.pb(u);
}
return mx;
}
void InitAnya(int N, int A[], int B[])
{
n=N;
for(int i=0;i<n;i++) E[i].clear();
for(int i=0;i<n;i++) mark[i]=0;
csz=0;marked.clear();
for(int i=0;i<n-1;i++)
{
E[A[i]].pb({B[i],i});
E[B[i]].pb({A[i],i});
}
DFS(0,-1);
}
void Pull(int u, int p)
{
for(auto e:E[u]) if(e.first!=p)
{
dep[e.first]+=dep[u];
Pull(e.first,u);
}
}
void Anya(int C[])
{
for(int i=0;i<n;i++) dep[i]=0;
for(int i=0;i<n-1;i++) dep[nod[i]]=C[i];
for(int i=0;i<n;i++) Save(i,dep[i]);
Pull(0,-1);
for(int i:marked)
{
for(int j=0;j<9;j++) Save(500+(mark[i]-1)*9+j,(dep[i]>>j)&1);
}
}
}
void InitAnya(int N, int A[], int B[])
{
_Anya::InitAnya(N,A,B);
}
void Anya(int C[])
{
_Anya::Anya(C);
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
namespace _Boris
{
const int M=505;
vector<pair<int,int>> E[M];
int nod[M],dep[M],n,par[M];
int mark[M],csz;
vector<int> marked;
int DFS(int u, int p)
{
int mx=0;
for(auto e:E[u]) if(e.first!=p)
{
nod[e.second]=e.first;
par[e.first]=u;
int now=DFS(e.first,u);
mx=max(mx,now);
}
mx++;
if(mx>=11)
{
mx=0;
mark[u]=++csz;
marked.pb(u);
}
return mx;
}
void InitBoris(int N, int A[], int B[])
{
n=N;
for(int i=0;i<n;i++) E[i].clear();
for(int i=0;i<n;i++) mark[i]=0;
csz=0;marked.clear();
for(int i=0;i<n-1;i++)
{
E[A[i]].pb({B[i],i});
E[B[i]].pb({A[i],i});
}
DFS(0,-1);
}
int Boris(int city)
{
int ans=0;
while(city!=0 && mark[city]==0)
{
ans+=Ask(city);
city=par[city];
}
if(mark[city])
{
for(int i=0;i<9;i++) ans+=Ask(500+(mark[city]-1)*9+i)<<i;
}
return ans;
}
}
void InitBoris(int N, int A[], int B[])
{
_Boris::InitBoris(N,A,B);
}
int Boris(int city)
{
return _Boris::Boris(city);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
784 KB |
Output is correct |
2 |
Correct |
4 ms |
780 KB |
Output is correct |
3 |
Correct |
6 ms |
860 KB |
Output is correct |
4 |
Correct |
7 ms |
1200 KB |
Output is correct |
5 |
Correct |
9 ms |
1264 KB |
Output is correct |
6 |
Correct |
9 ms |
1264 KB |
Output is correct |
7 |
Correct |
9 ms |
1396 KB |
Output is correct |
8 |
Correct |
9 ms |
1300 KB |
Output is correct |
9 |
Correct |
11 ms |
1212 KB |
Output is correct |
10 |
Correct |
10 ms |
1296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1332 KB |
Output is correct |
2 |
Correct |
10 ms |
1264 KB |
Output is correct |
3 |
Correct |
12 ms |
1384 KB |
Output is correct |
4 |
Correct |
13 ms |
1264 KB |
Output is correct |
5 |
Correct |
11 ms |
1264 KB |
Output is correct |
6 |
Correct |
10 ms |
1344 KB |
Output is correct |
7 |
Correct |
10 ms |
1372 KB |
Output is correct |
8 |
Correct |
11 ms |
1352 KB |
Output is correct |
9 |
Correct |
10 ms |
1392 KB |
Output is correct |
10 |
Correct |
10 ms |
1392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1772 KB |
Output is correct |
2 |
Correct |
20 ms |
1956 KB |
Output is correct |
3 |
Correct |
20 ms |
1776 KB |
Output is correct |
4 |
Correct |
20 ms |
1836 KB |
Output is correct |
5 |
Correct |
21 ms |
1828 KB |
Output is correct |
6 |
Correct |
21 ms |
1896 KB |
Output is correct |
7 |
Correct |
20 ms |
1904 KB |
Output is correct |
8 |
Correct |
20 ms |
1860 KB |
Output is correct |
9 |
Correct |
20 ms |
1776 KB |
Output is correct |
10 |
Correct |
20 ms |
1840 KB |
Output is correct |
11 |
Correct |
20 ms |
1832 KB |
Output is correct |
12 |
Correct |
20 ms |
1836 KB |
Output is correct |
13 |
Correct |
20 ms |
1872 KB |
Output is correct |
14 |
Correct |
20 ms |
1776 KB |
Output is correct |
15 |
Correct |
20 ms |
1828 KB |
Output is correct |
16 |
Correct |
20 ms |
1868 KB |
Output is correct |
17 |
Correct |
20 ms |
1864 KB |
Output is correct |
18 |
Correct |
20 ms |
1860 KB |
Output is correct |
19 |
Correct |
20 ms |
1776 KB |
Output is correct |
20 |
Correct |
20 ms |
1892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1836 KB |
Output is correct |
2 |
Correct |
19 ms |
1824 KB |
Output is correct |
3 |
Correct |
18 ms |
1824 KB |
Output is correct |
4 |
Correct |
19 ms |
1776 KB |
Output is correct |
5 |
Correct |
19 ms |
1824 KB |
Output is correct |
6 |
Correct |
18 ms |
1828 KB |
Output is correct |
7 |
Correct |
20 ms |
1776 KB |
Output is correct |
8 |
Correct |
18 ms |
1912 KB |
Output is correct |
9 |
Correct |
20 ms |
1872 KB |
Output is correct |
10 |
Correct |
18 ms |
1836 KB |
Output is correct |
11 |
Correct |
20 ms |
1776 KB |
Output is correct |
12 |
Correct |
18 ms |
1828 KB |
Output is correct |
13 |
Correct |
20 ms |
1776 KB |
Output is correct |
14 |
Correct |
20 ms |
1864 KB |
Output is correct |
15 |
Correct |
20 ms |
1776 KB |
Output is correct |
16 |
Correct |
18 ms |
1804 KB |
Output is correct |
17 |
Correct |
20 ms |
1824 KB |
Output is correct |
18 |
Correct |
20 ms |
1836 KB |
Output is correct |
19 |
Correct |
19 ms |
1828 KB |
Output is correct |
20 |
Correct |
19 ms |
1824 KB |
Output is correct |
21 |
Correct |
19 ms |
1824 KB |
Output is correct |
22 |
Correct |
19 ms |
1756 KB |
Output is correct |
23 |
Correct |
19 ms |
1776 KB |
Output is correct |
24 |
Correct |
19 ms |
1836 KB |
Output is correct |
25 |
Correct |
20 ms |
2044 KB |
Output is correct |
26 |
Correct |
19 ms |
1904 KB |
Output is correct |
27 |
Correct |
27 ms |
1824 KB |
Output is correct |
28 |
Correct |
19 ms |
1892 KB |
Output is correct |
29 |
Correct |
19 ms |
1824 KB |
Output is correct |
30 |
Correct |
20 ms |
1824 KB |
Output is correct |
31 |
Correct |
19 ms |
1776 KB |
Output is correct |
32 |
Correct |
17 ms |
1824 KB |
Output is correct |
33 |
Correct |
20 ms |
1776 KB |
Output is correct |
34 |
Correct |
18 ms |
1884 KB |
Output is correct |
35 |
Correct |
18 ms |
1828 KB |
Output is correct |
36 |
Correct |
19 ms |
1868 KB |
Output is correct |
37 |
Correct |
18 ms |
1828 KB |
Output is correct |
38 |
Correct |
19 ms |
1872 KB |
Output is correct |
39 |
Correct |
17 ms |
1820 KB |
Output is correct |
40 |
Correct |
18 ms |
1892 KB |
Output is correct |
41 |
Correct |
17 ms |
1912 KB |
Output is correct |
42 |
Correct |
17 ms |
1776 KB |
Output is correct |
43 |
Correct |
17 ms |
1820 KB |
Output is correct |
44 |
Correct |
17 ms |
1828 KB |
Output is correct |
45 |
Correct |
18 ms |
1820 KB |
Output is correct |
46 |
Correct |
17 ms |
1776 KB |
Output is correct |
47 |
Correct |
18 ms |
1820 KB |
Output is correct |
48 |
Correct |
17 ms |
1824 KB |
Output is correct |
49 |
Correct |
17 ms |
1952 KB |
Output is correct |
50 |
Correct |
17 ms |
1820 KB |
Output is correct |