//Suleyman Atayew
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define N 160
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) (int)(a.size())
ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; }
using namespace std;
int n;
int P[N];
int ata(int x)
{
if(x == P[x]) return x;
return P[x] = ata(P[x]);
}
void uni(int a, int b)
{
a = ata(a);
b = ata(b);
if(a == b) return;
P[b] = a;
}
int sora(int l, int r, int y)
{
int x = 0;
cout << r-l+1 + (y ? 1 : 0) << " ";
for(int i = l; i <= r; i++) cout << i << " ";
if(y) cout << y;
cout << "\n";
cout.flush();
cin >> x;
return x;
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i++) P[i] = i;
for(int i = 2; i <= n; i++) {
int cur = sora(1, i-1, 0);
int cur2 = sora(1, i, 0);
if(cur != cur2) continue;
int l = 1, r = i-1, md, ans = 0;
while(l <= r) {
md = (l+r)/2;
if(sora(l, md, 0) == sora(l, md, i)) {
r = md-1;
ans = md;
} else
l = md+1;
}
uni(ans, i);
}
cout << "0 ";
int sz = 0;
map <int, int> M;
for(int i = 1; i <= n; i++) {
if(M[ata(i)] == 0) M[ata(i)] = ++sz;
cout << M[ata(i)] << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
200 KB |
Output is correct |
2 |
Correct |
25 ms |
200 KB |
Output is correct |
3 |
Correct |
13 ms |
292 KB |
Output is correct |
4 |
Correct |
4 ms |
288 KB |
Output is correct |
5 |
Correct |
37 ms |
200 KB |
Output is correct |
6 |
Correct |
11 ms |
200 KB |
Output is correct |
7 |
Correct |
21 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
200 KB |
Output is correct |
2 |
Correct |
24 ms |
200 KB |
Output is correct |
3 |
Correct |
10 ms |
288 KB |
Output is correct |
4 |
Correct |
9 ms |
200 KB |
Output is correct |
5 |
Correct |
23 ms |
200 KB |
Output is correct |
6 |
Correct |
28 ms |
200 KB |
Output is correct |
7 |
Correct |
33 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
200 KB |
Output is correct |
2 |
Correct |
33 ms |
200 KB |
Output is correct |
3 |
Correct |
18 ms |
200 KB |
Output is correct |
4 |
Correct |
6 ms |
288 KB |
Output is correct |
5 |
Correct |
27 ms |
200 KB |
Output is correct |
6 |
Correct |
21 ms |
200 KB |
Output is correct |
7 |
Correct |
22 ms |
284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
200 KB |
Output is correct |
2 |
Correct |
30 ms |
200 KB |
Output is correct |
3 |
Correct |
9 ms |
200 KB |
Output is correct |
4 |
Correct |
6 ms |
200 KB |
Output is correct |
5 |
Correct |
20 ms |
272 KB |
Output is correct |
6 |
Correct |
17 ms |
200 KB |
Output is correct |
7 |
Correct |
30 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
200 KB |
Output is correct |
2 |
Correct |
21 ms |
200 KB |
Output is correct |
3 |
Correct |
20 ms |
200 KB |
Output is correct |
4 |
Correct |
18 ms |
272 KB |
Output is correct |
5 |
Correct |
19 ms |
200 KB |
Output is correct |
6 |
Correct |
9 ms |
280 KB |
Output is correct |
7 |
Correct |
10 ms |
320 KB |
Output is correct |