Submission #49923

# Submission time Handle Problem Language Result Execution time Memory
49923 2018-06-05T02:55:06 Z wzy Amusement Park (JOI17_amusement_park) C++14
0 / 100
66 ms 49728 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

int  peso[1000000] , label[1000000] , pai[1000000];

vector<int> adj[1000000];

int fd(int x){
	return pai[x] == x ? x : pai[x] = fd(pai[x]);
}

void join(int u , int v){
	u = fd(u) , v = fd(v);
	if(peso[u] < peso[v]) swap(u,v);
	pai[v] = u , peso[u] += peso[v];
}

void dfs(int i , int j){
	if(fd(i) != fd(j) && peso[fd(j)] < 60){
		join(i,j);
		label[i] = peso[fd(i)] - 1;
	}
	for(auto p : adj[i]){
		if(p == j) continue;
		dfs(p, i);
	}
}


void Joi(int N, int M, int A[], int B[], long long X, int T) {
  for(int i = 0 ; i < N ; i++){
  	pai[i] = i , peso[i] = 1;
  }
  for(int i = 0 ; i < M ; i++){
  	if(fd(A[i]) != fd(B[i])){
  		adj[A[i]].push_back(B[i]);
  		adj[B[i]].push_back(A[i]);
  		join(A[i] , B[i]);
  	}
  }
  for(int i = 0 ; i < N ; i ++){
  	peso[i] = 1 , pai[i] = i;
  }
  dfs(0,0);
  for(int i = 0 ; i < N ; i ++){
  	MessageBoard(i , X & (1ll<<label[i]));
  }
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

int  peso[1000000] , label[1000000] , pai[1000000];
vector<int> adj[1000000];

int fd(int x){
	return pai[x] == x ? x : pai[x] = fd(pai[x]);
}

void join(int u , int v){
	u = fd(u) , v = fd(v);
	if(peso[u] < peso[v]) swap(u,v);
	pai[v] = u , peso[u] += peso[v];
}

void dfs(int i , int j){
	if(fd(i) != fd(j) && peso[fd(j)] < 60){
		join(i,j);
		label[i] = peso[fd(i)] - 1;
	}
	for(auto p : adj[i]){
		if(p == j) continue;
		dfs(p, i);
	}
}

bool vis[1000000];
bool c[1000000];
long long ans = 0;
void solve(int x , int y){
	long long U = (1LL<<label[x]);
	U *= c[x];
	ans |= U;
	vis[x] = true;
	for(auto p : adj[x]){
		if(!vis[p] && fd(p) == fd(x)){
			c[p] = move(p);
			solve(p, x);
		}
	}
	if(x != y) move(y);
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	  for(int i = 0 ; i < N ; i++){
  	pai[i] = i , peso[i] = 1;
  }
  for(int i = 0 ; i < M ; i++){
  	if(fd(A[i]) != fd(B[i])){
  		adj[A[i]].push_back(B[i]);
  		adj[B[i]].push_back(A[i]);
  		join(A[i] , B[i]);
  	}
  }
  for(int i = 0 ; i < N ; i ++){
  	peso[i] = 1 , pai[i] = i;
  }
  dfs(0,0);
  c[P] = V;
  solve(P, P);
  return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 47712 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 49664 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 49664 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 49720 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 49728 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -