#include "dango3.h"
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define bug(x) cerr << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
//#define TEST
const int N = 50;
const int Mxm = 10005;
const int INF = 2e9;
int n, m;
bool inq[Mxm];
vector<int> v[N], pre[N], tmp;
#ifdef TEST
int a[N], cnt[N];
inline int Query(vector<int> &v)
{
cout << "? ";
for (int x : v) cout << x << ' '; cout << '\n';
int mn = INF;
for (int i=1; i <= n; ++i) cnt[i] = 0;
for (int x : v) ++cnt[a[x]];
for (int i=1; i <= n; ++i) mn = min(mn, cnt[i]);
int ret = mn;
cout << "ret = " << ret << '\n';
return ret;
}
inline void Answer(vector<int> &v)
{
cout << "! ";
for (int x : v) cout << x << ' '; cout << '\n';
}
#endif
inline bool chk(int id, int del_id)
{
for (int i=1; i <= n*m; ++i) inq[i] = 1;
inq[del_id] = 0;
for (int x : pre[id]) inq[x] = 0;
tmp.clear();
for (int i=1; i <= n*m; ++i) if (inq[i]) tmp.pb(i);
int ret = Query(tmp);
return ret == m - id;
}
void Solve(int t1, int t2)
{
n = t1, m = t2;
int i, j, k, tot=0;
for (i=1; i <= n*m; ++i)
{
int lb = 1, ub = tot + 1, mid;
while (lb < ub)
{
mid = (lb + ub) >> 1;
if (chk(mid, i)) ub = mid;
else lb = mid + 1;
}
//cout << "lb = " << lb << "\n\n";
tot = max(tot, lb);
v[lb].pb(i);
for (j=lb; j <= m; ++j) pre[j].pb(i);
}
for (i=1; i <= m; ++i) Answer(v[i]);
}
#ifdef TEST
int main(void)
{ IO
int i;
cin >> n >> m;
for (i=1; i <= n*m; ++i) cin >> a[i];
Solve(n, m);
return 0;
}
#endif
Compilation message
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:65:15: warning: unused variable 'k' [-Wunused-variable]
65 | int i, j, k, tot=0;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
344 KB |
Output is correct |
2 |
Correct |
12 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
528 KB |
Output is correct |
4 |
Correct |
15 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
600 KB |
Output is correct |
6 |
Correct |
10 ms |
540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
384 ms |
752 KB |
Output is correct |
2 |
Correct |
372 ms |
848 KB |
Output is correct |
3 |
Correct |
497 ms |
852 KB |
Output is correct |
4 |
Correct |
496 ms |
1088 KB |
Output is correct |
5 |
Correct |
333 ms |
848 KB |
Output is correct |
6 |
Correct |
323 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1529 ms |
1460 KB |
Output is correct |
2 |
Correct |
1505 ms |
1604 KB |
Output is correct |
3 |
Correct |
2029 ms |
1312 KB |
Output is correct |
4 |
Correct |
1971 ms |
1508 KB |
Output is correct |
5 |
Correct |
1273 ms |
1276 KB |
Output is correct |
6 |
Correct |
1258 ms |
1364 KB |
Output is correct |