This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
static int getL;
static const int MAX_N = 100;
static vector<int> gp[MAX_N+1];
static vector<pair<int, int> > edge;
static int p[MAX_N+1];
static int n;
static void dfs(int x){
for(auto i : gp[x]){
if(i==p[x]) continue;
p[i] = x; dfs(i);
}
}
void InitAnya(int N , int A[] , int B[]) {
n = N;
for(int i=0; i<N-1; i++){
edge.push_back({A[i], B[i]});
gp[A[i]].push_back(B[i]); gp[B[i]].push_back(A[i]);
}
dfs(0);
}
static int cnt[MAX_N+1];
static void dfs2(int x){
if(x!=0){
cnt[x]+=cnt[p[x]];
}
for(auto i:gp[x]){
if(i==p[x]) continue;
dfs2(i);
}
}
void Anya(int C[]) {
for(int i=0; i<n; i++) cnt[i] = 0;
for(int i=0; i<edge.size(); i++){
if(C[i]){
if(p[edge[i].first] == edge[i].second) cnt[edge[i].first]++;
else cnt[edge[i].second]++;
}
}
dfs2(0);
for(int i=0; i<n; i++){
for(int j=0; j<10; j++){
Save(i*10+j, cnt[i]%2); cnt[i]/=2;
}
}
}
#include "Borislib.h"
void InitBoris(int N , int A[] , int B[]) {
}
int Boris(int city) {
int ans = 0;
int two = 1;
for(int i=0; i<10; i++){
ans += Ask(city*10+i) * two;
two*=2;
}
return ans;
}
Compilation message (stderr)
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:42:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<edge.size(); i++){
~^~~~~~~~~~~~
Anya.cpp: At global scope:
Anya.cpp:6:12: warning: 'getL' defined but not used [-Wunused-variable]
static int getL;
^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |