#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
int n,m;
void boqn(vector<int> pozicii, int cn, int cm)
{
/*cout<<"davam: "<<cn<<" "<<cm<<"\n";
for (int q=0;q<pozicii.size();q++) cout<<pozicii[q]<<" ";
cout<<"\n";*/
if (cm==1)
{
Answer(pozicii);
return;
}
/*int l=0,r=cn*cm;
vector<int> zaqu;
while (l<r-1)
{
int mid=(l+r)/2;
zaqu.clear();
for (int q=0;q<=mid;q++) zaqu.push_back(pozicii[q]);
int qu=Query(zaqu);
//cout<<l<<" "<<mid<<" "<<r<<" "<<qu<<"\n";
if (qu<cm/2) l=mid;
else r=mid;
}*/
//cout<<r<<"\n";
vector<int> pyrvo,vtoro;
int r=0;
for (r=0;r<cn*cm;r++)
{
pyrvo.push_back(pozicii[r]);
if (Query(pyrvo)==cm/2) break;
}
for (int q=0;q<=r;q++) pyrvo.push_back(pozicii[q]);
for (int q=r+1;q<cn*cm;q++) vtoro.push_back(pozicii[q]);
for (int q=r-1;q>=0;q--)
{
int poq=pyrvo[q];
swap(pyrvo[pyrvo.size()-1],pyrvo[q]);
pyrvo.pop_back();
int qu=Query(pyrvo);
//cout<<"mahnah "<<poq<<" "<<" i stana "<<qu<<"\n";
if (qu<cm/2)
{
pyrvo.push_back(poq);
swap(pyrvo[pyrvo.size()-1],pyrvo[q]);
}
else
{
vtoro.push_back(poq);
}
}
boqn(pyrvo,cn,cm/2);
boqn(vtoro,cn,cm-cm/2);
}
void Solve(int N, int M) {
n=N;
m=M;
vector<int> og;
for (int q=1;q<=n*m;q++) og.push_back(q);
boqn(og,n,m);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
608 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
604 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |