Submission #49925

# Submission time Handle Problem Language Result Execution time Memory
49925 2018-06-05T03:08:14 Z wzy Amusement Park (JOI17_amusement_park) C++14
0 / 100
70 ms 50568 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 ++){
  	long long Z = X;
  	long long T = (1LL<<label[i]);
  	assert(label[i] < 60);
  	long long U = Z & T;
  	if(U > 0) U = 1;
  	MessageBoard(i , U);
  }
}
#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 47 ms 47728 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 50120 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 50280 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 50520 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 50568 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -