답안 #149985

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149985 2019-09-01T07:30:03 Z CHT를 사랑하는 모임(#3587, moonrabbit2, Retro3014, gs18115) 갈라파고스 여행 (FXCUP4_island) C++17
31 / 100
5000 ms 54580 KB
#include "island.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int,int> TP;
typedef vector<vector<ll>> mat;
const int N=3e5+5;
const ll mod=1e9+7;
int n,m,k,a[N],u[N],v[N];
int par[N]; vector<int> g[N];
vector<int> gp[N]; // 소속되었던 그룹 번호들
map<pii,int> mp;
int fi(int x)
{
	if(par[x]==x) return x;
	return par[x]=fi(par[x]);
}
void un(int x,int y,int t)
{
	x=fi(x); y=fi(y);
	if(g[x].size()<g[y].size()) swap(x,y);
	par[y]=x;
	for(auto &it : g[y]){
		if(mp[{x,a[it]}]) continue;
		gp[a[it]].push_back(x);
		g[x].push_back(it);
		//cout<<x<<" with "<<y<<" : "<<it<<" , "<<a[it]<<" , "<<x<<" , "<<t<<endl;
		mp[{x,a[it]}]=t;
	}
}
void Init(int K, std::vector<int> F, std::vector<int> S, std::vector<int> E){
	n=F.size(); m=S.size(); k=K;
	for(int i=0;i<n;i++) a[i+1]=F[i]+1;
	for(int i=0;i<m;i++) u[i+1]=S[i]+1,v[i+1]=E[i]+1;
	for(int i=1;i<=n;i++){
		par[i]=i;
		gp[a[i]].push_back(i);
		g[i].push_back(i);
		mp[{i,a[i]}]=m+1;
	}
	for(int i=m;i>=1;i--){
		if(fi(u[i])==fi(v[i])) continue;
		un(u[i],v[i],i);
	}
}
int Separate(int a,int b)
{
	a++; b++;
	int ans=1;
	for(auto &g : gp[a]){
		if(!mp[{g,b}]) continue;
		else ans=max(ans,min(mp[{g,a}],mp[{g,b}]));
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 974 ms 53820 KB Output is correct
2 Correct 1002 ms 53812 KB Output is correct
3 Correct 962 ms 53940 KB Output is correct
4 Correct 828 ms 54580 KB Output is correct
5 Correct 1012 ms 54068 KB Output is correct
6 Correct 831 ms 54076 KB Output is correct
7 Correct 811 ms 53692 KB Output is correct
8 Correct 810 ms 53940 KB Output is correct
9 Correct 905 ms 53692 KB Output is correct
10 Correct 1014 ms 54204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 14544 KB Output is correct
2 Correct 15 ms 14464 KB Output is correct
3 Execution timed out 5101 ms 36412 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 14544 KB Output is correct
2 Correct 15 ms 14464 KB Output is correct
3 Correct 974 ms 53820 KB Output is correct
4 Correct 1002 ms 53812 KB Output is correct
5 Correct 962 ms 53940 KB Output is correct
6 Correct 828 ms 54580 KB Output is correct
7 Correct 1012 ms 54068 KB Output is correct
8 Correct 831 ms 54076 KB Output is correct
9 Correct 811 ms 53692 KB Output is correct
10 Correct 810 ms 53940 KB Output is correct
11 Correct 905 ms 53692 KB Output is correct
12 Correct 1014 ms 54204 KB Output is correct
13 Execution timed out 5101 ms 36412 KB Time limit exceeded
14 Halted 0 ms 0 KB -