답안 #26186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26186 2017-06-28T08:50:53 Z 서규호(#1097) Snowy Roads (JOI16_snowy) C++14
35 / 100
22 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],tcnt[502];
static vector<pair<int,int>> edge[502];
static bool check[502],memo[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);
	for(int i=1; i<N; i++) tcnt[lev[i]%10]++;
	int small = 100000,it;
	for(int i=0; i<10; i++){
		if(small > tcnt[i]){
			small = tcnt[i];
			it = i;
		}
	}
	for(int i=1; i<N; i++) if(lev[i]%10 == it) memo[i] = true;
}

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(!memo[i]) 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 get gett

#define pb push_back

using namespace std;

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

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

void InitBoris(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});
	}
	dfs(0);
	for(int i=1; i<N; i++){
		if(!memo[i]) continue;
		where[i] = cnt;
		cnt += 10;
	}
}

int Boris(int city) {
	ans = 0;
	while(!memo[city]){
		ans += Ask(cnt+get[city]);
		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: In function 'void InitAnya(int, int*, int*)':
Anya.cpp:43:25: warning: 'it' may be used uninitialized in this function [-Wmaybe-uninitialized]
  for(int i=1; i<N; i++) if(lev[i]%10 == it) memo[i] = true;
                         ^
Anya.cpp: At global scope:
Anya.cpp:8:12: warning: 'getL' defined but not used [-Wunused-variable]
 static int getL;
            ^
Anya.cpp:10:14: warning: 'bucket' defined but not used [-Wunused-variable]
 static int N,bucket = 10;
              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4184 KB Output is correct
2 Correct 0 ms 4184 KB Output is correct
3 Correct 0 ms 4184 KB Output is correct
4 Correct 0 ms 4184 KB Output is correct
5 Correct 0 ms 4184 KB Output is correct
6 Correct 6 ms 4184 KB Output is correct
7 Correct 3 ms 4184 KB Output is correct
8 Correct 6 ms 4184 KB Output is correct
9 Incorrect 0 ms 4184 KB Wrong Answer [4]
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4184 KB Output is correct
2 Incorrect 3 ms 4184 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 22 ms 4184 KB Output is correct
3 Correct 13 ms 4184 KB Output is correct
4 Correct 13 ms 4184 KB Output is correct
5 Correct 9 ms 4184 KB Output is correct
6 Correct 16 ms 4184 KB Output is correct
7 Correct 12 ms 4184 KB Output is correct
8 Correct 12 ms 4184 KB Output is correct
9 Correct 16 ms 4184 KB Output is correct
10 Correct 13 ms 4184 KB Output is correct
11 Correct 12 ms 4184 KB Output is correct
12 Correct 12 ms 4184 KB Output is correct
13 Correct 16 ms 4184 KB Output is correct
14 Correct 16 ms 4184 KB Output is correct
15 Correct 13 ms 4184 KB Output is correct
16 Correct 13 ms 4184 KB Output is correct
17 Correct 12 ms 4184 KB Output is correct
18 Correct 13 ms 4184 KB Output is correct
19 Correct 9 ms 4184 KB Output is correct
20 Correct 16 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 4184 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -