Submission #972160

# Submission time Handle Problem Language Result Execution time Memory
972160 2024-04-30T07:58:55 Z hotboy2703 Super Dango Maker (JOI22_dango3) C++17
22 / 100
8880 ms 1408 KB
#include "dango3.h"

#include <bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL<<(i))
#define sz(a) (ll((a).size()))
namespace {
    vector <ll> color[401];
    mt19937_64 rng(69420);
}

void Solve(int n,int m) {
    vector <ll> a(n*m);
    iota(a.begin(),a.end(),1);
    shuffle(a.begin(),a.end(),rng);
    ll rem = m;
    set <ll> lft;
    for (ll i = 1;i <= n * m;i ++)lft.insert(i);
    auto alldif = [&](vector <ll> x) -> bool{
        for (auto y:x)lft.erase(y);
        vector <ll> tmp(lft.begin(),lft.end());
//        cout<<"CHECK DIF "<<endl;
//        for (auto y:x)cout<<y<<' ';
//        cout<<'\n';
//        for (auto y:tmp)cout<<y<<' ';
//        cout<<'\n';
        for (auto y:x)lft.insert(y);
        return (Query(tmp) == rem - 1);

    };
    for (ll i = 0;i < n * m;i ++){
        ll id = a[i];
        vector <ll> x;
        for (ll j = 1;j <= n;j ++){
            if (sz(color[j]))x.push_back(color[j][0]);
        }
        x.push_back(id);
        if (sz(x) <= n && alldif(x)){
//            cout<<"WOW"<<endl;
            for (ll j = 1;j <= n;j ++){
                if (!sz(color[j])){color[j].push_back(id);break;}
            }
        }
        else{
            x.pop_back();
            ll l = 0;
            ll r = sz(x) - 1;
            ll found = -1;
            while (l <= r){
                ll mid = (l + r) >> 1;
                vector <ll> tmp;
                for (ll i = 0;i <= mid;i ++)tmp.push_back(x[i]);
                tmp.push_back(id);
                if (alldif(tmp)){
                    l = mid + 1;
                }
                else{
                    found = x[mid];
                    r = mid - 1;
                }
            }
            for (ll j = 1;j <= n;j ++){
                if (sz(color[j]) && color[j][0] == found){color[j].push_back(id);break;}
            }
        }
        ll cnt = 0;
        for (ll j = 1;j <= n;j ++){
            if (sz(color[j]))cnt++;
        }
        if (cnt == n){
            vector <ll> ans;
            for (ll j = 1;j <= n;j ++){
                ans.push_back(color[j].back());
                color[j].pop_back();
            }
            Answer(ans);
            for (auto x:ans)lft.erase(x);
            rem--;
        }
//        cout<<"POSITION\n";
//        for (ll i = 1;i <= n;i ++){
//            for (auto x:color[i])cout<<x<<' ';
//            cout<<'\n';
//        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 348 KB Output is correct
2 Correct 82 ms 344 KB Output is correct
3 Correct 84 ms 344 KB Output is correct
4 Correct 86 ms 548 KB Output is correct
5 Correct 88 ms 568 KB Output is correct
6 Correct 84 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2310 ms 848 KB Output is correct
2 Correct 2399 ms 848 KB Output is correct
3 Correct 2481 ms 852 KB Output is correct
4 Correct 2563 ms 840 KB Output is correct
5 Correct 2473 ms 832 KB Output is correct
6 Correct 2417 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8880 ms 1408 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -