답안 #26178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26178 2017-06-28T08:31:55 Z 서규호(#1097) Snowy Roads (JOI16_snowy) C++14
0 / 100
15 ms 4180 KB
#include "Anyalib.h"
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

static int getL;

static int N,bucket = 10;
static int ans[502];
static vector<int> edge[502];
static bool check[502];
static int par[502],lev[502];

static void dfs(int x){
	check[x] = true;
	for(auto &i : edge[x]){
		if(check[i]) continue;
		par[i] = x;
		lev[i] = lev[x]+1;
		dfs(i);
	}
}

void InitAnya(int n , int A[] , int B[]) {
	N = n;
	for(int i=0; i<N-1; i++){
		edge[A[i]].pb(B[i]);
		edge[B[i]].pb(A[i]);
	}
	dfs(0);
}

void Anya(int C[]) {
	for(int i=0; i<N-1; i++){
		ans[i+1] = ans[i]+C[i];
	}
	int cnt = 0;
	for(int i=1; i<N; i++){
		if(lev[i]%bucket != 0) continue;
		int x = ans[i];
		for(int j=1; j<=10; j++){
			Save(cnt++,x%2);
			x /= 2;
		}
	}
	for(int i=0; i<N-1; i++){
		Save(cnt++,C[i]);
	}
}
#include "Borislib.h"
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

static int N,ans,bucket = 10,cnt;
static vector<int> edge[502];
static bool check[502];
static int par[502],lev[502],where[502];

static void dfs(int x){
	check[x] = true;
	for(auto &i : edge[x]){
		if(check[i]) continue;
		par[i] = x;
		lev[i] = lev[x]+1;
		dfs(i);
	}
}

void InitBoris(int n , int A[] , int B[]) {
	N = n;
	for(int i=0; i<N-1; i++){
		edge[A[i]].pb(B[i]);
		edge[B[i]].pb(A[i]);
	}
	dfs(0);
	for(int i=1; i<N; i++){
		if(lev[i]%bucket != 0) continue;
		where[i] = cnt;
		cnt += 10;
	}
}

int Boris(int city) {
	ans = 0;
	while(lev[city]%bucket != 0){
		ans += Ask(cnt+city-1);
		city = par[city];
	}
	if(city == 0) return ans;
	for(int i=where[city]; i<where[city]+10; i++) ans += Ask(i);

	return ans;
}

Compilation message

Anya.cpp:8:12: warning: 'getL' defined but not used [-Wunused-variable]
 static int getL;
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4180 KB Output is correct
2 Incorrect 0 ms 4180 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4180 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 4180 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 4180 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -