Submission #892316

# Submission time Handle Problem Language Result Execution time Memory
892316 2023-12-25T07:23:07 Z vjudge1 Super Dango Maker (JOI22_dango3) C++17
22 / 100
220 ms 764 KB
#include <bits/stdc++.h>

#include "dango3.h"

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
//#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

void Solve(int n, int m){
    vector <int> p, us(n * m + 1);
    for ( int i = 1; i <= n * m; i++ ){
        p.pb(i);
    }
    auto nxt = [&](){
        vector <int> a;
        for ( int i = 1; i <= n * m; i++ ){
            if ( !us[i] ){
                a.pb(i);
            }
        } swap(p, a);
    };
    for ( int op = 1; op <= m; op++ ){
        auto get = [&](int lst){
            int l = 0, r = lst;
            while ( l < r ){
                int md = (l + r) >> 1;
                vector <int> q;
                for ( int i = 0; i <= md; i++ ){
                    q.pb(p[i]);
                }
                if ( Query(q) < 2 ){
                    l = md + 1;
                } else r = md;
            }
            return l;
        };
        auto dfs = [&](auto dfs, int lst, auto &cur) -> void{
            if ( lst == -1 ){
                return;
            }
            int l = 0, r = lst;
            while ( l < r ){
                int md = (l + r) >> 1;
                auto q = cur;
                for ( int i = 0; i <= md; i++ ){
                    q.pb(p[i]);
                }
                if ( Query(q) ) r = md;
                else l = md + 1;
            }
            us[p[l]] = true;
            cur.pb(p[l]);
            dfs(dfs, l - 1, cur);
        };
        vector <int> tmp;
        if ( op == m ){
            Answer(p);
        } else{
            int s = p.size(),  ps = get(s - 1);
            dfs(dfs, ps, tmp);
            Answer(tmp);
            tmp.clear(); nxt();
            dfs(dfs, ps - n, tmp);
            Answer(tmp);
            nxt(); op++;
        }
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 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 4 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 9 ms 544 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 604 KB Output is correct
2 Correct 51 ms 604 KB Output is correct
3 Correct 220 ms 604 KB Output is correct
4 Correct 217 ms 652 KB Output is correct
5 Correct 22 ms 600 KB Output is correct
6 Correct 22 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 764 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -