Submission #26188

# Submission time Handle Problem Language Result Execution time Memory
26188 2017-06-28T08:56:09 Z 서규호(#1097) None (JOI16_snowy) C++14
100 / 100
22 ms 4188 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]%bucket]++;
	int small = 100000,it;
	for(int i=0; i<bucket; i++){
		if(small > tcnt[i]){
			small = tcnt[i];
			it = i;
		}
	}
	for(int i=1; i<N; i++) if(lev[i]%bucket == 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],tcnt[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;
		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);
	int small = 10000000,it;
	for(int i=1; i<N; i++) tcnt[lev[i]%bucket]++;
	for(int i=0; i<bucket; i++){
		if(small > tcnt[i]){
			small = tcnt[i];
			it = i;
		}
	}
	for(int i=1; i<N; i++) if(lev[i]%bucket == it) memo[i] = true;
	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] && city != 0){
		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]%bucket == it) memo[i] = true;
                         ^
Anya.cpp: At global scope:
Anya.cpp:8:12: warning: 'getL' defined but not used [-Wunused-variable]
 static int getL;
            ^

Boris.cpp: In function 'void InitBoris(int, int*, int*)':
Boris.cpp:41:25: warning: 'it' may be used uninitialized in this function [-Wmaybe-uninitialized]
  for(int i=1; i<N; i++) if(lev[i]%bucket == it) memo[i] = true;
                         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4188 KB Output is correct
2 Correct 0 ms 4188 KB Output is correct
3 Correct 0 ms 4188 KB Output is correct
4 Correct 6 ms 4188 KB Output is correct
5 Correct 9 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
7 Correct 6 ms 4188 KB Output is correct
8 Correct 3 ms 4188 KB Output is correct
9 Correct 6 ms 4188 KB Output is correct
10 Correct 6 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4188 KB Output is correct
2 Correct 6 ms 4188 KB Output is correct
3 Correct 6 ms 4188 KB Output is correct
4 Correct 6 ms 4188 KB Output is correct
5 Correct 6 ms 4188 KB Output is correct
6 Correct 6 ms 4188 KB Output is correct
7 Correct 6 ms 4188 KB Output is correct
8 Correct 6 ms 4188 KB Output is correct
9 Correct 3 ms 4188 KB Output is correct
10 Correct 6 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4188 KB Output is correct
2 Correct 16 ms 4188 KB Output is correct
3 Correct 16 ms 4188 KB Output is correct
4 Correct 16 ms 4188 KB Output is correct
5 Correct 19 ms 4188 KB Output is correct
6 Correct 16 ms 4188 KB Output is correct
7 Correct 16 ms 4188 KB Output is correct
8 Correct 22 ms 4188 KB Output is correct
9 Correct 16 ms 4188 KB Output is correct
10 Correct 19 ms 4188 KB Output is correct
11 Correct 16 ms 4188 KB Output is correct
12 Correct 15 ms 4188 KB Output is correct
13 Correct 12 ms 4188 KB Output is correct
14 Correct 12 ms 4188 KB Output is correct
15 Correct 12 ms 4188 KB Output is correct
16 Correct 12 ms 4188 KB Output is correct
17 Correct 9 ms 4188 KB Output is correct
18 Correct 12 ms 4188 KB Output is correct
19 Correct 16 ms 4188 KB Output is correct
20 Correct 13 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 4188 KB Output is correct
2 Correct 16 ms 4188 KB Output is correct
3 Correct 12 ms 4188 KB Output is correct
4 Correct 16 ms 4188 KB Output is correct
5 Correct 12 ms 4188 KB Output is correct
6 Correct 12 ms 4188 KB Output is correct
7 Correct 16 ms 4188 KB Output is correct
8 Correct 16 ms 4188 KB Output is correct
9 Correct 12 ms 4188 KB Output is correct
10 Correct 16 ms 4188 KB Output is correct
11 Correct 16 ms 4188 KB Output is correct
12 Correct 16 ms 4188 KB Output is correct
13 Correct 12 ms 4188 KB Output is correct
14 Correct 22 ms 4188 KB Output is correct
15 Correct 16 ms 4188 KB Output is correct
16 Correct 12 ms 4188 KB Output is correct
17 Correct 16 ms 4188 KB Output is correct
18 Correct 12 ms 4188 KB Output is correct
19 Correct 9 ms 4188 KB Output is correct
20 Correct 12 ms 4188 KB Output is correct
21 Correct 12 ms 4188 KB Output is correct
22 Correct 13 ms 4188 KB Output is correct
23 Correct 19 ms 4188 KB Output is correct
24 Correct 9 ms 4188 KB Output is correct
25 Correct 16 ms 4188 KB Output is correct
26 Correct 16 ms 4188 KB Output is correct
27 Correct 16 ms 4188 KB Output is correct
28 Correct 16 ms 4188 KB Output is correct
29 Correct 19 ms 4188 KB Output is correct
30 Correct 19 ms 4188 KB Output is correct
31 Correct 12 ms 4188 KB Output is correct
32 Correct 12 ms 4188 KB Output is correct
33 Correct 16 ms 4188 KB Output is correct
34 Correct 16 ms 4188 KB Output is correct
35 Correct 12 ms 4188 KB Output is correct
36 Correct 16 ms 4188 KB Output is correct
37 Correct 12 ms 4188 KB Output is correct
38 Correct 19 ms 4188 KB Output is correct
39 Correct 12 ms 4188 KB Output is correct
40 Correct 12 ms 4188 KB Output is correct
41 Correct 16 ms 4188 KB Output is correct
42 Correct 12 ms 4188 KB Output is correct
43 Correct 12 ms 4188 KB Output is correct
44 Correct 9 ms 4188 KB Output is correct
45 Correct 16 ms 4188 KB Output is correct
46 Correct 16 ms 4188 KB Output is correct
47 Correct 12 ms 4188 KB Output is correct
48 Correct 9 ms 4188 KB Output is correct
49 Correct 9 ms 4188 KB Output is correct
50 Correct 12 ms 4188 KB Output is correct