답안 #49951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49951 2018-06-05T05:23:41 Z wzy Amusement Park (JOI17_amusement_park) C++14
0 / 100
41 ms 8216 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

static int Ps[100000] , Pi[100000];
static vector<int> ad[100000];
static int lJOI[100000];
int findjoi(int x){
	return Pi[x] == x ? x : Pi[x] = findjoi(Pi[x]);
}

void joinjoi(int x , int y){
	x = findjoi(x) , y = findjoi(y);
	if(Ps[x] > Ps[y]) swap(x,y);
	Pi[x] = y , Ps[y] += Ps[x];
}


void dfsJOI(int x , int y){
	if(findjoi(x) != findjoi(y) && (Ps[findjoi(x)] +Ps[findjoi(y)]) <= 60){
		joinjoi(x , y);
	}
	lJOI[x] = Ps[findjoi(x)] - 1;
	for(auto p : ad[x]){
		if(p == y) continue;
		dfsJOI(p , x);
	}
}




void Joi(int N, int M, int A[], int B[], long long X, int T) {
  for(int i = 0 ; i < N ; i ++){
  	Ps[i] = 1 , Pi[i] = i;
  }
  for(int i = 0 ; i < M ; i ++){
  	if(findjoi(A[i]) != findjoi(B[i])){
  		joinjoi(A[i] , B[i]);
  		ad[A[i]].push_back(B[i]);
  		ad[B[i]].push_back(A[i]);
  	}
  }
  for(int i = 0 ; i < N ; i ++){
  	Ps[i] = 1 , Pi[i] = i;
  }
  dfsJOI(0 , 0);
  long long P = 0;
  for(int i = 0 ; i < N ; i ++){
  	int U = (1LL<<(lJOI[i]));
  	U &= X;
  	if(U > 0) U = 1;
  	else U = 0;
    P += (1LL<<lJOI[i])*U;
  	MessageBoard(i , U);
  }

}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

static int pai[100000] , peso[100000] , lioi[100000] ;
static vector<int> adj[100000];
static long long ans = 0;
static bool vis[100000] , c[100000];
int fd(int x ){
	return pai[x] == x ? x : pai[x] = fd(pai[x]);
}

void join(int x , int y){
	x = fd(x ) ,y = fd(y);
	if(peso[x] > peso[y]) swap(x,y);
	pai[x] = y , peso[y] += peso[x];
}

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

void solve(int x , int y){
	if(x != y){
		if(c[x]) ans |= (1LL<<lioi[x]);
	}
	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 ++){
  	peso[i] = 1 , pai[i] = i;
  }
  for(int i = 0 ; i < M ; i ++){
  	if(fd(A[i]) != fd(B[i])){
  		join(A[i] , B[i]);
  		adj[A[i]].push_back(B[i]);
  		adj[B[i]].push_back(A[i]);
  	}
  }
  for(int i = 0 ; i < N ; i ++){
  	peso[i] = 1 , pai[i] = i;
  }
  dfs(0 , 0);
  if(V) ans |= (1LL<<lioi[P]);
  solve(P,P);
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 5724 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 7920 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 7920 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 8144 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 8216 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -