제출 #568428

#제출 시각아이디문제언어결과실행 시간메모리
568428Theo830Unscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
4 ms596 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "messy.h"
int N;
void build(int l,int r){
    if(l == r){
        return;
    }
    string x = "";
    int mid = (l+r)/2;
    f(i,0,N){
        if(i < l || i > r){
            x += "1";
        }
        else{
            x += "0";
        }
    }
    f(i,mid+1,r+1){
        x[i] = '1';
        cout<<x<<endl;
        add_element(x);
        x[i] = '0';
    }
    build(l,mid);
    build(mid+1,r);
}
vector<int>ans;
void solve(int l,int r,vector<int> arr){
    if(l == r){
        assert(arr.size() == 1);
        ans[arr[0]] = l;
        return;
    }
    int mid = (l+r)/2;
    vector<int>exo[2];
    string x = "";
    f(i,0,N){
        x += "1";
    }
    for(auto y:arr){
        x[y] = '0';
    }
    for(auto y:arr){
        x[y] = '1';
        cout<<x<<" "<<y<<endl;
        exo[check_element(x)].pb(y);
        x[y] = '0';
    }
    solve(l,mid,exo[0]);
    solve(mid+1,r,exo[1]);
}
vector<int> restore_permutation(int n, int w, int r) {
    N = n;
    ans.assign(N,0);
    build(0,n-1);
    compile_set();
    vector<int>arr;
    f(i,0,n){
        arr.pb(i);
    }
    solve(0,n-1,arr);
    return ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...