Submission #257576

# Submission time Handle Problem Language Result Execution time Memory
257576 2020-08-04T12:27:25 Z sjimed None (JOI16_snowy) C++14
35 / 100
20 ms 2036 KB
#include "Anyalib.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> pipii;
const int inf = 1e9;
const ll INF = 1e18;

static int n;
static vector<int> g[555];
static int a[555];
static int b[555];
static bool chk[555];
static int d[555];
static int num[555];
static int cost[555];
static int p[555];
static int dist[555];
static int cnt = 500;

static void dfs(int x) {
	for(auto i : g[x]) {
		if(i == p[x]) continue;

		p[i] = x;
		dfs(i);

		d[x] = max(d[x], d[i] + 1);
	}

	if(d[x] == 10) {
		num[x] = cnt;
		cnt += 9;
		chk[x] = true;
		d[x] = -1;
	}
}

static void dep(int x) {
	//cout << x << " " << dist[x] << endl;
	for(auto i : g[x]) {
		if(i == p[x]) continue;

		dist[i] = dist[x] + cost[i];

		dep(i);
	}
}

void InitAnya(int N , int A[] , int B[]) {
	n = N;

	for(int i=0; i<n-1; i++) {
		a[i] = A[i], b[i] = B[i];

		g[a[i]].eb(b[i]);
	}

	dfs(0);
}

void Anya(int C[]) {
	for(int i=0; i<n-1; i++) {
		if(p[a[i]] == b[i]) cost[a[i]] = C[i];
		else cost[b[i]] = C[i];
		
		Save(i, C[i]);
	}

	dep(0);

	for(int i=0; i<n; i++) {
		if(!chk[i]) continue;

		for(int j=num[i]; j < num[i] + 9; j++) {
			if(dist[i] & (1 << j - num[i])) Save(j, 1);
			else Save(j, 0);
		}
	}
}
#include "Borislib.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> pipii;
const int inf = 1e9;
const ll INF = 1e18;

static int n;
static vector<int> g[555];
static int a[555];
static int b[555];
static bool chk[555];
static int d[555];
static int p[555];
static int num[555];
static int cnt = 500;
static int edge[555];

static void dfs(int x) {
	for(auto i : g[x]) {
		if(i == p[x]) continue;

		p[i] = x;
		dfs(i);

		d[x] = max(d[x], d[i] + 1);
	}

	if(d[x] == 10) {
		num[x] = cnt;
		cnt += 9;
		chk[x] = true;
		d[x] = -1;
	}
}

void InitBoris(int N , int A[] , int B[]) {
	n = N;

	for(int i=0; i<n-1; i++) {
		a[i] = A[i], b[i] = B[i];

		g[a[i]].eb(b[i]);
	}

	dfs(0);

	for(int i=0; i<n-1; i++) {
		if(p[a[i]] == b[i]) edge[a[i]] = i;
		else edge[b[i]] = i;
	}

}

int Boris(int city) {
	int i;
	int ans = 0;
	for(i = city; i != 0 && !chk[i]; i = p[i]) {
		ans += Ask(edge[i]);

		//cout << i << " " << ans << endl;
	}

	if(i == 0) return ans;

	for(int j = num[i]; j < num[i] + 9; j++) {
		(ans += Ask(j) << (j - num[i]));
	}

	//cout << i << " " << ans << endl;

	return ans;
}

Compilation message

Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:89:25: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    if(dist[i] & (1 << j - num[i])) Save(j, 1);
                       ~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 916 KB Output is correct
2 Incorrect 2 ms 992 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1904 KB Output is correct
2 Correct 17 ms 1792 KB Output is correct
3 Correct 17 ms 1848 KB Output is correct
4 Correct 18 ms 1912 KB Output is correct
5 Correct 15 ms 1792 KB Output is correct
6 Correct 16 ms 2032 KB Output is correct
7 Correct 16 ms 1848 KB Output is correct
8 Correct 20 ms 1792 KB Output is correct
9 Correct 16 ms 1792 KB Output is correct
10 Correct 16 ms 1904 KB Output is correct
11 Correct 16 ms 1792 KB Output is correct
12 Correct 17 ms 1808 KB Output is correct
13 Correct 17 ms 1792 KB Output is correct
14 Correct 17 ms 1916 KB Output is correct
15 Correct 17 ms 1848 KB Output is correct
16 Correct 17 ms 2036 KB Output is correct
17 Correct 17 ms 1792 KB Output is correct
18 Correct 18 ms 1864 KB Output is correct
19 Correct 16 ms 1912 KB Output is correct
20 Correct 17 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1804 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -