답안 #37594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37594 2017-12-26T08:53:24 Z grumpy_gordon Amusement Park (JOI17_amusement_park) C++14
10 / 100
15 ms 25248 KB
#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;

const int maxn = 1e5 + 100;

vector<int> e[maxn];

int n;

int parent[maxn];

int h[maxn];

int get(int x){
  	return x == parent[x] ? x : parent[x] = get(parent[x]);
}

bool uni(int x, int y){
  	x = get(x);
  	y = get(y);
  	if (x == y)
		return 0;
  	parent[x] = y;
  	return 1;
}

int poi[maxn];

void predfs(int v, int par){
  for (auto i : e[v])
	if (i != par)
      	poi[i] = v, h[i] = h[v] + 1, predfs(i, v);
}

pair<int, int> mas[maxn];

vector<int> q[maxn];

int pos[maxn];

bool good[maxn];

void make(int v, int par, int st){
  	q[st].push_back(v);
  	for (auto i : e[v])
		if (i != par && good[i])
			make(i, v, st);
}

void Joi(int N, int M, int A[], int B[], long long X, int T){
	n = N;	
	for (int i = 0; i < n; i++)
      parent[i] = i;
  	for (int i = 0; i < M; i++)
	if (uni(A[i], B[i])){
      e[A[i]].push_back(B[i]);
      e[B[i]].push_back(A[i]);
    }
  	predfs(0, -1);
  	for (int i = 0; i < n; i++)
      	mas[i] = make_pair(h[i], i);
  	sort(mas, mas + n);
	for (int i = 0; i < 60; i++)
      	good[mas[i].second] = 1, pos[mas[i].second] = i;
  	for (int i = 0; i < 60; i++)
		make(mas[i].second, -1, mas[i].second);
  	for (int i = 60; i < n; i++){
      	int v = poi[i];
      	q[i] = q[v];
      	pos[i] = pos[q[i].back()];
      	q[i].pop_back();
      	q[i].insert(q[i].begin(), i);
    }
  	for (int i = 0; i < n; i++)
      MessageBoard(i, ((1ll << pos[i]) & X) > 0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;

const int maxn = 1e5 + 100;

vector<int> e[maxn];

int n;

int parent[maxn];

int h[maxn];

int get(int x){
  	return x == parent[x] ? x : parent[x] = get(parent[x]);
}

bool uni(int x, int y){
  	x = get(x);
  	y = get(y);
  	if (x == y)
		return 0;
  	parent[x] = y;
  	return 1;
}

int poi[maxn];

void predfs(int v, int par){
  for (auto i : e[v])
	if (i != par)
      	poi[i] = v, h[i] = h[v] + 1, predfs(i, v);
}

pair<int, int> mas[maxn];

vector<int> q[maxn];

int pos[maxn];

bool good[maxn];

void make(int v, int par, int st){
  	q[st].push_back(v);
  	for (auto i : e[v])
		if (i != par && good[i])
			make(i, v, st);
}

long long ans;

void go(int v, int par, vector<int> &g, int &id, int val){
  	ans += (1ll << pos[v]) * val;
  	if (id < 60){
      	for (auto i : e[v])
			if (i == g[id])
              	id++, go(i, v, g, id, Move(i));
    }
  	if (par != -1)
		Move(par);
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T){
	n = N;	
	for (int i = 0; i < n; i++)
      parent[i] = i;
  	for (int i = 0; i < M; i++)
	if (uni(A[i], B[i])){
      e[A[i]].push_back(B[i]);
      e[B[i]].push_back(A[i]);
    }
  	predfs(0, -1);
  	for (int i = 0; i < n; i++)
      	mas[i] = make_pair(h[i], i);
  	sort(mas, mas + n);
	for (int i = 0; i < 60; i++)
      	good[mas[i].second] = 1, pos[mas[i].second] = i;
  	for (int i = 0; i < 60; i++)
		make(mas[i].second, -1, mas[i].second);
  	for (int i = 60; i < n; i++){
      	int v = poi[i];
      	q[i] = q[v];
      	pos[i] = pos[q[i].back()];
      	q[i].pop_back();
      	q[i].insert(q[i].begin(), i);
    }
  	int ss = 1;
  	go(P, -1, q[P], ss, V);
  	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 19024 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 19024 KB Output is correct
2 Correct 3 ms 19024 KB Output is correct
3 Correct 0 ms 19024 KB Output is correct
4 Correct 0 ms 20080 KB Output is correct
5 Correct 0 ms 20080 KB Output is correct
6 Correct 3 ms 20080 KB Output is correct
7 Correct 3 ms 20080 KB Output is correct
8 Correct 0 ms 20080 KB Output is correct
9 Correct 12 ms 25248 KB Output is correct
10 Correct 12 ms 25244 KB Output is correct
11 Correct 15 ms 25244 KB Output is correct
12 Correct 0 ms 19024 KB Output is correct
13 Correct 3 ms 19024 KB Output is correct
14 Correct 0 ms 19024 KB Output is correct
15 Correct 3 ms 19024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -