#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
using namespace std;
// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD
typedef long long ll;
typedef pair<int, int> pii;
int ret[155];
int n;
bool match(int a, int b) {
cout << 2 << " " << a << " " << b << endl;
int t;
cin >> t;
return t == 1;
}
int qry(int lhs, int rhs) {
cout << rhs-lhs+1;
for(int i = lhs; i <= rhs; i++) cout << " " << i;
cout << endl;
int t;
cin >> t;
return t;
}
void solve() {
cin >> n;
int k = qry(1, n);
memset(ret, 1, sizeof(ret));
int last = k;
for(int i = n-1; i >= 1; i--) {
int a = qry(1, i);
if(a != last) {
ret[i+1] = last--;
assert(a == last);
}
}
ret[1] = 1;
for(int i = n; i >= 1; i--) {
if(ret[i] <= k) continue;
for(int j = i-1; j >= 1; j--) {
if(ret[j] > k) continue;
if(match(i, j)) {
ret[i] = ret[j];
break;
}
}
assert(ret[i] <= k);
}
// done - print the answer
cout << 0;
for(int i = 1; i <= n; i++) cout << " " << ret[i];
cout << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
17 ms |
376 KB |
Output is correct |
3 |
Correct |
14 ms |
248 KB |
Output is correct |
4 |
Correct |
12 ms |
380 KB |
Output is correct |
5 |
Correct |
9 ms |
376 KB |
Output is correct |
6 |
Correct |
11 ms |
300 KB |
Output is correct |
7 |
Correct |
20 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
376 KB |
Output is correct |
2 |
Correct |
23 ms |
248 KB |
Output is correct |
3 |
Correct |
12 ms |
376 KB |
Output is correct |
4 |
Correct |
12 ms |
248 KB |
Output is correct |
5 |
Correct |
17 ms |
248 KB |
Output is correct |
6 |
Correct |
15 ms |
376 KB |
Output is correct |
7 |
Correct |
17 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
13 ms |
248 KB |
Output is correct |
3 |
Correct |
24 ms |
248 KB |
Output is correct |
4 |
Correct |
11 ms |
380 KB |
Output is correct |
5 |
Correct |
22 ms |
248 KB |
Output is correct |
6 |
Correct |
29 ms |
248 KB |
Output is correct |
7 |
Correct |
24 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
248 KB |
Output is correct |
2 |
Correct |
10 ms |
248 KB |
Output is correct |
3 |
Correct |
19 ms |
248 KB |
Output is correct |
4 |
Correct |
8 ms |
248 KB |
Output is correct |
5 |
Correct |
31 ms |
248 KB |
Output is correct |
6 |
Correct |
31 ms |
248 KB |
Output is correct |
7 |
Correct |
15 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
248 KB |
Output is correct |
2 |
Correct |
17 ms |
376 KB |
Output is correct |
3 |
Correct |
23 ms |
248 KB |
Output is correct |
4 |
Correct |
21 ms |
376 KB |
Output is correct |
5 |
Correct |
28 ms |
376 KB |
Output is correct |
6 |
Correct |
25 ms |
248 KB |
Output is correct |
7 |
Correct |
12 ms |
248 KB |
Output is correct |