# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815868 | Pikachu | Carnival (CEOI14_carnival) | C++17 | 77 ms | 316 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
template<typename T>
inline bool maxi(T &x, const T &val)
{
if (x < val) return x = val, true;
return false;
}
template<typename T>
inline bool mini(T &x, const T &val)
{
if (x > val) return x = val, true;
return false;
}
const int maxn = 155;
int n;
int ans[maxn];
int par[maxn];
int findpar(int x)
{
if (par[x]) return par[x] = findpar(par[x]);
return x;
}
void unite(int u, int v)
{
u = findpar(u);
v = findpar(v);
if (u != v) par[u] = v;
}
int getInt()
{
int tmp;
cin >> tmp;
return tmp;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
cout << 2 << ' ' << i << ' ' << j << endl;
if (getInt() == 1) unite(i, j);
}
}
int cnt = 0;
for (int i = 1; i <= n; i++) {
int x = findpar(i);
if (ans[x]) ans[i] = ans[x];
else {
ans[i] = ans[x] = ++cnt;
}
}
cout << "0 ";
for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
cout << endl;
}
signed main()
{
#ifdef LOCAL
clock_t st = clock();
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
#define Task ""
#ifdef LOCAL
if (!fopen("D:\\.inp", "r")) {
freopen("D:\\.inp", "w", stdout);
freopen("D:\\.out", "w", stdout);
cerr << "get input from file\n";
return 0;
}
freopen("D:\\.inp", "r", stdin);
freopen("D:\\.out", "w", stdout);
#else
if (fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
#endif
solve();
#ifdef LOCAL
cerr << clock() - st << endl;
#endif
}
Compilation message (stderr)
# | 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... |