#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const double PI = 4 * atan(1);
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>
#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
void fast_io(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
void io(string taskname){
string fin = taskname + ".in";
string fout = taskname + ".out";
const char* FIN = fin.c_str();
const char* FOUT = fout.c_str();
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
fast_io();
}
const int MAX = 155;
int res[MAX];
int par[MAX], sz[MAX];
void init(){
for(int i = 0; i<MAX; i++){
par[i] = i;
sz[i] = 1;
}
}
int get(int x){
if(par[x] != x){
par[x] = get(par[x]);
}
return par[x];
}
bool unite(int x, int y){
// cout << x << " united " << y << endl;
x = get(x);
y = get(y);
if(x == y){
return false;
}
if(sz[x] < sz[y]){
swap(x, y);
}
sz[x] += sz[y];
par[y] = x;
return true;
}
int ask(vi x){
sort(all(x));
cout << sz(x) << " ";
for(int i: x) cout << i+1 << " ";
cout << endl;
int ret;
cin >> ret;
return ret;
}
vi comb(vi a, int b){
vi ret;
for(int x: a) ret.eb(x);
ret.eb(b);
return ret;
}
vi range(int l, int r){
vi ret;
f1r(i, l, r+1) ret.eb(i);
return ret;
}
int val(int l, int r){
set<int> s;
f1r(i, l, r+1) s.insert(get(i));
return sz(s);
}
void check(int x, int l, int r){
if(l == r){
if(ask(comb(range(l, r), x)) == 2) return;
else unite(x, l);
return;
}
if(l>r) return;
int m = (l + r)/2;
int res = ask(comb(range(l, r), x));
if(res == val(l, r)){
check(x, l, m);
check(x, m+1, r);
}
}
void divide(int l, int r){
if(l == r) return;
if(r<l) return;
if(r-l == 1){
int res = ask(range(l, r));
if(res == 2) return;
else unite(l, r);
return;
}
int m = (l + r)/2;
divide(l, m);
divide(m+1, r);
f1r(i, l, m+1){
check(i, m+1, r);
}
}
unordered_map<int, int> um;
int main(){
fast_io();
int n;
cin >> n;
init();
divide(0, n-1);
set<int> s;
vi ans;
f0r(i, n){
//cout << get(i) << " ";
ans.eb(get(i));
s.insert(get(i));
}
int cnt = 0;
for(auto x: s){
um[x] = cnt;
cnt++;
}
cout << 0 << " ";
for(int x: ans) cout << um[x]+1 << " ";
cout << endl;
return 0;
}
Compilation message
carnival.cpp:1:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
carnival.cpp: In function 'void io(std::__cxx11::string)':
carnival.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FIN, "r", stdin);
~~~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FOUT, "w", stdout);
~~~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
69 ms |
248 KB |
Partially correct |
2 |
Correct |
34 ms |
376 KB |
Output is correct |
3 |
Correct |
13 ms |
376 KB |
Output is correct |
4 |
Correct |
11 ms |
376 KB |
Output is correct |
5 |
Incorrect |
119 ms |
332 KB |
Too much parties are held |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
119 ms |
248 KB |
Partially correct |
2 |
Correct |
24 ms |
328 KB |
Output is correct |
3 |
Correct |
12 ms |
376 KB |
Output is correct |
4 |
Correct |
14 ms |
376 KB |
Output is correct |
5 |
Incorrect |
105 ms |
248 KB |
Too much parties are held |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
424 KB |
Too much parties are held |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
332 KB |
Too much parties are held |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
248 KB |
Too much parties are held |
2 |
Halted |
0 ms |
0 KB |
- |