답안 #202184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202184 2020-02-14T04:59:34 Z Segtree Amusement Park (JOI17_amusement_park) C++14
0 / 100
38 ms 3500 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include"Joi.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
vector<ll> g[10010],f[10010];
ll vis[10010],dep[10010];
void dfs1(ll x,ll from,ll d){
    if(vis[x])return;
    dep[x]=d;
    if(from!=-1){
	f[x].push_back(from);
	f[from].push_back(x);
    }
    for(auto y:g[x]){
	dfs1(y,x,d+1);
    }
}
ll col[10010],uma;
void dfs(ll x,ll from){
    col[x]=uma; uma++;
    for(auto y:f[x])if(y!=from){
	if(uma==60)return;
	dfs(y,x);
    }
}

void Joi(int N,int M,int A[],int B[],ll X,int T){
    rep(i,N)vis[i]=0;
    uma=0;
    dfs1(0,-1,0);
    rep(i,N)col[i]=dep[i]%60;
    dfs(0,-1);
    for(int i=0;i<N;i++){
	MessageBoard(i,!!(X&(1LL<<(i%60))));
    }
}
//----------------

/*int main(){
    
}*/


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include"Ioi.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod

vector<ll> g[10010],f[10010];
ll vis[10010],dep[10010];
void dfs1(ll x,ll from,ll d){
    if(vis[x])return;
    dep[x]=d;
    if(from!=-1){
	f[x].push_back(from);
	f[from].push_back(x);
    }
    for(auto y:g[x]){
	dfs1(y,x,d+1);
    }
}
ll par[10010];
ll col[10010],uma;
void dfs(ll x,ll from){
    par[x]=from;
    col[x]=uma; uma++;
    for(auto y:f[x])if(y!=from){
	if(uma==60)return;
	dfs(y,x);
    }
}

int ges[60];
bool perf(){
 rep(k,60)if(ges[k]!=-1)return 0;
 return 1;   
}
ll calc(){
    ll ans=0;
    rep(k,60){
	ans+=(1LL<<k)*ges[k];
    }
    return ans;
}

ll dd(ll x,ll from){
    if(from!=-1)ges[col[x]]=Move(x);
    for(auto y:f[x])if(y!=from){
	if(perf())return calc();
	dd(y,x);
	Move(x);
    }
    return -1;
}

ll Ioi(int N,int M,int A[],int B[],int P,int V,int T){
    rep(i,N)vis[i]=0;
    uma=0;
    dfs1(0,-1,0);
    rep(i,N)col[i]=dep[i]%60;
    dfs(0,-1);
    
    rep(k,60)ges[k]=-1;
    while(P!=0){
	ges[col[P]]=V;
	if(perf()){
	    return calc();
	}
	P=par[P];
	V=Move(P);
    }
    ges[col[0]]=V;
    return dd(0,-1);
}
/*int main(){
    
}*/


# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1800 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 3492 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1800 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 3500 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 3492 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -