답안 #26181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26181 2017-06-28T08:38:10 Z 서규호(#1097) Snowy Roads (JOI16_snowy) C++14
35 / 100
19 ms 4184 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<pair<int,int>> edge[502];
static bool check[502];
static int par[502],lev[502];
static int a[502],b[502],c[502];

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

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

void dfs2(int x){
	check[x] = true;
	for(auto &i : edge[x]){
		if(check[i.first]) continue;
		ans[i.first] = ans[x]+c[i.second];
		dfs2(i.first);
	}
}

void Anya(int C[]) {
	for(int i=0; i<N-1; i++) c[i] = C[i];
	for(int i=0; i<N; i++) check[i] = false;
	dfs2(0);
	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;
	int two = 1;
	for(int i=where[city]; i<where[city]+10; i++){
		ans += two*Ask(i);
		two *= 2;
	}

	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 4184 KB Output is correct
2 Incorrect 0 ms 4184 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4184 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4184 KB Output is correct
3 Correct 19 ms 4184 KB Output is correct
4 Correct 16 ms 4184 KB Output is correct
5 Correct 16 ms 4184 KB Output is correct
6 Correct 12 ms 4184 KB Output is correct
7 Correct 19 ms 4184 KB Output is correct
8 Correct 12 ms 4184 KB Output is correct
9 Correct 12 ms 4184 KB Output is correct
10 Correct 16 ms 4184 KB Output is correct
11 Correct 9 ms 4184 KB Output is correct
12 Correct 16 ms 4184 KB Output is correct
13 Correct 16 ms 4184 KB Output is correct
14 Correct 12 ms 4184 KB Output is correct
15 Correct 16 ms 4184 KB Output is correct
16 Correct 12 ms 4184 KB Output is correct
17 Correct 16 ms 4184 KB Output is correct
18 Correct 16 ms 4184 KB Output is correct
19 Correct 16 ms 4184 KB Output is correct
20 Correct 13 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 4184 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -