제출 #1154574

#제출 시각아이디문제언어결과실행 시간메모리
1154574zhasyn사육제 (CEOI14_carnival)C++20
20 / 100
26 ms436 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1000002022;
ll um(ll a, ll b){
	return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
int p[N], sz[N], pos[N];
int gt(int x){
	if(p[x] == x) return x;
	else return p[x] = gt(p[x]);
}
void addthem(int a, int b){
	a = gt(a);
	b = gt(b);
	if(a != b){
		if(sz[b] > sz[a]) swap(a, b);
		sz[a] += sz[b];
		p[b] = a;
	}
}
int main(){
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	int n;
  	cin >> n;
  	for(int i = 1; i <= n; i++){
  		p[i] = i;
  		sz[i] = 1;
  	}
  	for(int i = 1; i <= n; i++){
  		for(int j = i + 1, x; j <= n; j++){
  			cout << 2 << " "<< i << " "<< j << endl;
  			cin >> x;
  			if(x == 1) addthem(i, j);
  		}
  	}
  	int cnt = 1;
  	for(int i = 1; i <= n; i++){
  		if(gt(i) == i) {
  			pos[i] = cnt++;
  		}
  	}
  	cout << 0 << " ";
  	for(int i = 1; i <= n; i++){
  		cout << pos[p[i]] << " ";
  	}
  return 0;
}
 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...