답안 #361667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361667 2021-01-31T04:17:45 Z Marlov 사육제 (CEOI14_carnival) C++14
20 / 100
119 ms 492 KB
/*
Code by @marlov       
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

#define maxN 155

int N;
int tc=0;
int tg=0;
int p[maxN];
int r[maxN];
bool decided[maxN];

int findP(int n){
	if(n==p[n]) return n;
	int pv=findP(p[n]);
	p[n]=pv;
	return pv;
}

void combine(int a,int b){
	int p1=findP(a);
	int p2=findP(b);
	if(r[p1]<r[p2]) swap(p1,p2);
	p[p2]=p1;
	r[p1]=max(r[p1],r[p2]+1);
	tg--;
}

int tv=1;
map<int,int> toV;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>N;
	tg=N;
	for(int i=0;i<N;i++){
		p[i]=i;
		r[i]=1;
	}
	cout<<N<<" ";
	for(int i=0;i<N;i++){
		cout<<i+1<<" ";
	}
	cout<<endl;
	cin>>tc;
	for(int i=0;i<N;i++){
		if(decided[i]) continue;
		if(tg==tc) break;
		for(int j=i+1;j<N;j++){
			if(decided[j]) continue;
			cout<<"2 "<<i+1<<" "<<j+1<<endl;
			int gv;
			cin>>gv;
			if(gv==1){
				decided[j]=true;
				combine(i,j);
			}
		}
		decided[i]=true;
	}
	cout<<"0 ";
	for(int i=0;i<N;i++){
		if(toV.count(findP(i))==0){
			toV[findP(i)]=tv;
			tv++;
		}
		cout<<toV[findP(i)]<<" ";
	}
	cout<<endl;
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1,n=0?)
	* do smth instead of nothing and stay organized
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 19 ms 364 KB Output is correct
3 Partially correct 29 ms 396 KB Partially correct
4 Partially correct 64 ms 492 KB Partially correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 16 ms 364 KB Output is correct
3 Partially correct 39 ms 416 KB Partially correct
4 Partially correct 64 ms 492 KB Partially correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Partially correct 34 ms 396 KB Partially correct
4 Partially correct 68 ms 364 KB Partially correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 22 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Partially correct 72 ms 364 KB Partially correct
4 Partially correct 111 ms 364 KB Partially correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 8 ms 364 KB Output is correct
7 Correct 21 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 11 ms 364 KB Output is correct
3 Partially correct 76 ms 364 KB Partially correct
4 Partially correct 76 ms 364 KB Partially correct
5 Correct 8 ms 492 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Partially correct 119 ms 364 KB Partially correct