#include <bits/stdc++.h>
#include "Anyalib.h"
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<vector<P>> G;
vector<int> a,b;
int id;
int n;
void InitAnya(int N,int A[],int B[]){
n=N;
a.resize(N-1);
b.resize(N-1);
for(int i=0;i<N-1;i++){
a[i]=A[i];
b[i]=B[i];
}
}
void dfs(int i,int p,int sum,int dep){
if(dep%10==0){
for(int i=0;i<10;i++){
if(sum&(1<<i)){
Save(n+id*10+i,1);
}
}
id++;
}
for(auto e:G[i]){
if(e.first==p)continue;
Save(e.first,e.second);
dfs(e.first,i,sum+e.second,dep+1);
}
}
void Anya(int C[]){
G.clear();
G.resize(n);
id=0;
for(int i=0;i<n-1;i++){
G[a[i]].push_back(P(b[i],C[i]));
G[b[i]].push_back(P(a[i],C[i]));
}
dfs(0,-1,0,0);
}
#include <bits/stdc++.h>
#include "Borislib.h"
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<vector<int>> G;
vector<int> a,b,idx,par,d;
int n,id;
void dfs(int i,int p,int dep){
if(dep%10==0){
idx[i]=id;
id++;
}
d[i]=dep;
par[i]=p;
for(auto e:G[i]){
if(e==p)continue;
dfs(e,i,dep+1);
}
}
void InitBoris(int N,int A[],int B[]){
n=N;
a.resize(N-1);
b.resize(N-1);
idx.resize(n,-1);
par.resize(n,-1);
d.resize(n);
G.resize(n);
id=0;
for(int i=0;i<N-1;i++){
a[i]=A[i];
b[i]=B[i];
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
}
dfs(0,-1,0);
}
int Boris(int city){
int v=city;
int res=0;
while(1){
if(d[v]%10==0){
int k=idx[v];
for(int i=0;i<10;i++){
if(Ask(n+10*k+i)){
res+=(1<<i);
}
}
break;
}else{
res+=Ask(v);
}
v=par[v];
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
784 KB |
Output is correct |
2 |
Correct |
5 ms |
780 KB |
Output is correct |
3 |
Correct |
7 ms |
824 KB |
Output is correct |
4 |
Correct |
10 ms |
1076 KB |
Output is correct |
5 |
Correct |
12 ms |
1280 KB |
Output is correct |
6 |
Correct |
13 ms |
1312 KB |
Output is correct |
7 |
Correct |
12 ms |
1280 KB |
Output is correct |
8 |
Correct |
14 ms |
1072 KB |
Output is correct |
9 |
Correct |
12 ms |
1280 KB |
Output is correct |
10 |
Correct |
13 ms |
1072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1280 KB |
Output is correct |
2 |
Correct |
13 ms |
1372 KB |
Output is correct |
3 |
Correct |
14 ms |
1376 KB |
Output is correct |
4 |
Correct |
15 ms |
1288 KB |
Output is correct |
5 |
Correct |
15 ms |
1288 KB |
Output is correct |
6 |
Correct |
17 ms |
1280 KB |
Output is correct |
7 |
Correct |
15 ms |
1280 KB |
Output is correct |
8 |
Correct |
14 ms |
1296 KB |
Output is correct |
9 |
Correct |
17 ms |
1280 KB |
Output is correct |
10 |
Correct |
14 ms |
1292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
1320 KB |
Output is correct |
2 |
Correct |
34 ms |
1884 KB |
Output is correct |
3 |
Correct |
34 ms |
1892 KB |
Output is correct |
4 |
Correct |
34 ms |
1844 KB |
Output is correct |
5 |
Correct |
34 ms |
1844 KB |
Output is correct |
6 |
Correct |
36 ms |
1868 KB |
Output is correct |
7 |
Correct |
36 ms |
1852 KB |
Output is correct |
8 |
Correct |
38 ms |
1776 KB |
Output is correct |
9 |
Correct |
37 ms |
1844 KB |
Output is correct |
10 |
Correct |
38 ms |
1868 KB |
Output is correct |
11 |
Correct |
34 ms |
1844 KB |
Output is correct |
12 |
Correct |
37 ms |
1776 KB |
Output is correct |
13 |
Correct |
40 ms |
2040 KB |
Output is correct |
14 |
Correct |
38 ms |
1880 KB |
Output is correct |
15 |
Correct |
39 ms |
1852 KB |
Output is correct |
16 |
Correct |
37 ms |
1776 KB |
Output is correct |
17 |
Correct |
46 ms |
1840 KB |
Output is correct |
18 |
Correct |
40 ms |
1848 KB |
Output is correct |
19 |
Correct |
34 ms |
1852 KB |
Output is correct |
20 |
Correct |
41 ms |
1844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
768 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |