This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector <int> gg[35];
void Solve(int n, int m) {
    for (int i=1;i<=n*m;i++)
    {
        int left=1;
        int right=m;
        int ans;
        //cerr<<i<<'\n';
        while (left<=right)
        {
            int mid=(left+right)/2;
            vector <int> need;
            vector <bool> kk(n*m+5,false);
            for (int j=1;j<=mid;j++)
            {
                for (auto v:gg[j])
                {
                    kk[v]=true;
                }
            }
            kk[i]=true;
            for (int j=1;j<=n*m;j++)
            {
                if (kk[j]==false)
                {
                    need.pb(j);
                }
            }
            //cout<<mid<<" "<<need.size()<<" "<<m-mid<<" "<<Query(need)<<'\n';
            if (Query(need)>=m-mid)
            {
                ans=mid;
                right=mid-1;
            }
            else left=mid+1;
        }
        //cout<<i<<" "<<ans<<'\n';
        gg[ans].push_back(i);
    }
    for (int i=1;i<=m;i++)
    {
        Answer(gg[i]);
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |