#include <bits/stdc++.h>
#include "dango3.h"
#define ll int
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define mpa make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define bc back()
#define ar array
#define vll vector<ll>
using namespace std;
void Solve(ll n,ll m) {
ll i,j,q;
vector<ll> lst;
vector<vll> col(n+5);
set<ll> st;
for(i=1;i<=n*m;i++)st.ins(i);
for(i=1;i<n;i++){
vector<ll> cur;
ll mn[m+5],mx[m+5];
for(j=0;j<=m;j++){
mn[j]=st.sz;
mx[j]=0;
}
for(j=1;j<=m;j++){
ll l=mx[j-1],r=mn[j];
cout<<l<<' '<<r<<endl;
while(l+1<r){
ll mid=(l+r)/2;
vector<ll> v=lst;
auto it=st.begin();
for(q=0;q<mid;q++){
v.pb(*it);
it++;
}
ll x=Query(v);
if(x>0)r=mid;
else l=mid;
if(x>1)mn[x]=min(mn[x],mid);
}
auto it=st.begin();
for(q=1;q<r;q++)it++;
if(mn[j+1]>=r)mn[j+1]--;
mx[j]=r-1;
cur.pb(*it);
st.erase(it);
}
for(auto j : cur){
col[i].pb(j);
lst.pb(j);
}
}for(auto i : st){
col[n].pb(i);
}/*
for(i=1;i<=n;i++){
for(auto j : col[i])cout<<j<<' ';
cout<<endl;
}*/
for(i=1;i<=m;i++){
vector<ll> v;
for(j=1;j<=n;j++){
v.pb(col[j].bc);
col[j].pop_back();
}
Answer(v);
}
}
/*
3 2
3 3 1 2 1 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Do not print anything to standard output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Do not print anything to standard output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
792 KB |
Do not print anything to standard output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
630 ms |
1156 KB |
Do not print anything to standard output |
2 |
Halted |
0 ms |
0 KB |
- |