Submission #923700

# Submission time Handle Problem Language Result Execution time Memory
923700 2024-02-07T15:18:50 Z alexdd Super Dango Maker (JOI22_dango3) C++17
100 / 100
112 ms 856 KB
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int> ord;
vector<int> favec(vector<int> cv, int mij)
{
    vector<int> aux = cv;
    for(int j=0;j<=mij;j++)
        aux.push_back(ord[j]);
    return aux;
}
void scoate_unu()
{
    random_shuffle(ord.begin(),ord.end());
    int ult = ord.size();
    vector<int> cv;
    for(int i=1;i<=n;i++)
    {
        int st,dr,mij,ans=ult-1;
        if(i==ult || !Query(favec(cv,ult-2)))
            ans=ult-1;
        else
        {
            st=0;
            dr=ult-1;
            while(st<=dr)
            {
                mij=(st+dr)/2;

                if(Query(favec(cv,mij)))
                {
                    ans=mij;
                    dr=mij-1;
                }
                else
                    st=mij+1;
            }
        }
        cv.push_back(ord[ans]);
        ult=ans;
        ord.erase(ord.begin()+ans);
    }
    Answer(cv);
}
void Solve(int N, int M)
{
    n=N;
    m=M;
    for(int i=1;i<=n*m;i++)
        ord.push_back(i);
    random_shuffle(ord.begin(),ord.end());
    for(int i=1;i<m;i++)
        scoate_unu();
    Answer(ord);
}
/**

3 2
3 3 1 2 1 2

*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 604 KB Output is correct
2 Correct 26 ms 600 KB Output is correct
3 Correct 27 ms 604 KB Output is correct
4 Correct 26 ms 604 KB Output is correct
5 Correct 26 ms 604 KB Output is correct
6 Correct 27 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 600 KB Output is correct
2 Correct 104 ms 604 KB Output is correct
3 Correct 109 ms 756 KB Output is correct
4 Correct 111 ms 768 KB Output is correct
5 Correct 110 ms 764 KB Output is correct
6 Correct 112 ms 756 KB Output is correct