#pragma GCC optimize("Ofast,O2,O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << "[" << H << "]";
debug_out(T...);
}
#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define SZ(s) ((int)s.size())
#define all(x) (x).begin(), (x).end()
#define lla(x) (x).rbegin(), (x).rend()
clock_t startTime;
double getCurrentTime() {
return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}
#define MP make_pair
typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.000001;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e5 + 3e2;
const int M = 222;
int p[N];
int find(int x){
return (x == p[x] ? x : p[x] = find(p[x]));
}
void unite(int x, int y){
x = find(x);
y = find(y);
if (x == y) return;
if (rng() & 1) swap(x, y);
p[x] = y;
}
vector<int> mv(int l, int r){
vector<int> res;
while (l <= r) res.push_back(l++);
return res;
}
int sz(vector<int> v){
set<int> s;
for (int i : v) s.insert(find(i));
return s.size();
}
bool local = false;
int secret[N];
int queries = 0;
int ask(vector<int> v){
queries++;
if (local){
set<int> s;
for (int i : v) s.insert(secret[i]);
return s.size();
}
cout << v.size() << ' ';
for (int i : v) cout << i << ' ';
cout << endl;
int res;
cin >> res;
return res;
}
void solve(int TC) {
int n;
cin >> n;
// local = true;
if (local){
for (int i = 1; i <= n; i++) cin >> secret[i];
}
iota(p + 1, p + n + 1, 1);
for (int i = 1; i < n; i++){
int l = i + 1, r = n;
int ind = i;
while (l <= r){
int m = (l + r) >> 1;
if (ask(mv(i, m)) == sz(mv(i, m))){
ind = m;
l = m + 1;
} else r = m - 1;
}
if (ind == n) continue;
l = i, r = ind;
ind++;
int ind2 = i;
while (l <= r){
int m = (l + r) >> 1;
if (ask(mv(m, ind + 1)) < sz(mv(m, ind + 1))){
ind2 = m;
l = m + 1;
} else r = m - 1;
}
unite(ind, ind2);
debug(ind, ind2);
}
map<int, int> mp;
for (int i = 1; i <= n; i++){
int x = find(i);
if (mp.find(x) == mp.end()) mp[x] = mp.size() + 1;
}
cout << 0 << ' ';
for (int i = 1; i <= n; i++){
cout << mp[find(i)] << ' ';
}
cout << endl;
debug(queries);
}
int main() {
startTime = clock();
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef dddxxz
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
int TC = 1;
//cin >> TC;
for (int test = 1; test <= TC; test++) {
//debug(test);
//cout << "Case #" << test << ": ";
solve(test);
}
cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl;
return 0;
}
Compilation message
carnival.cpp: In function 'void solve(int)':
carnival.cpp:19:20: warning: statement has no effect [-Wunused-value]
19 | #define debug(...) 42
| ^~
carnival.cpp:127:9: note: in expansion of macro 'debug'
127 | debug(ind, ind2);
| ^~~~~
carnival.cpp:19:20: warning: statement has no effect [-Wunused-value]
19 | #define debug(...) 42
| ^~
carnival.cpp:142:5: note: in expansion of macro 'debug'
142 | debug(queries);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
204 KB |
Integer 12 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
200 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |