이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=155,MAXA=1e6+5,INF=1e9;
const double EPS=1e-9;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; }
ll n,m,k,q,x,y,z,input;
string s,t;
ifstream in;
vector<int> dsu;
#ifdef ONLINE_JUDGE
#define in cin
#endif
int root(int x){
while(x!=dsu[x]){
dsu[x]=dsu[dsu[x]];
x=dsu[x];
}
return x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
dsu.resize(n+1);
iota(all(dsu),0);
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
cout<<2<<" "<<i<<" "<<j<<endl;
cin>>input;
if(input==1) dsu[i]=j;
}
}
vector<int> ret;
map<int,int> mp;
int tmp=0;
for(int i=1;i<=n;i++){
ret.pb(root(i));
}
for(int i=0;i<n;i++){
if(!mp[ret[i]]){
mp[ret[i]]=++tmp;
}
}
for(int i=0;i<n;i++){
ret[i]=mp[ret[i]];
}
cout<<0<<" ";
for(auto v:ret){
cout<<v<<" ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |