Submission #854676

# Submission time Handle Problem Language Result Execution time Memory
854676 2023-09-28T13:16:03 Z sunwukong123 Unscrambling a Messy Bug (IOI16_messy) C++14
70 / 100
2 ms 856 KB
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN =1005;
const int inf=1000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi; 
int out[MAXN];
int n;
void send(vector<int>&on){
    string s(n,'0');
    for(auto x:on)s[x]='1';
    add_element(s);
}
set<int> s;
void dnc(int st, int en,vector<int> pre){
    if(st==en){
        return;
    }

    int mi=(st+en)/2;
    for(int i=mi+1;i<=en;i++){
        pre.push_back(i);send(pre);
        pre.pop_back();
    }
    pre.push_back(mi+1-st);
    dnc(st,mi,pre);
    dnc(mi+1,en,pre);
}
int div(int n){
    int r=0;
    while(n>1){
        n/=2;
        r++;
    }
    return r;
}
vector<int> restore_permutation(int n, int w, int r) {
    ::n=n;
    int m=div(n);
    for(int i=2;i<n;i++){
        if(__builtin_popcount(i) == 1){
            string str(n,'1');
            str[i]='0';
            add_element(str);
        }
    }
    vector<int>vec;
    dnc(0,n-1,vec);
    compile_set();

    set<int> impt;
    for(int i=0;i<n;i++){
        string str(n,'1');
        str[i]='0';
        if(check_element(str))impt.insert(i);
    }
    vector<int> pref;

    for(int b=m-1;b>=0;b--){
        int nb=-1;
        for(int i=0;i<n;i++){
            string str(n,'0');
            for(auto x:pref)str[x]='1';
            if(str[i] == '1')continue;
            str[i]='1';
            if(check_element(str)){

                if(impt.find(i)!=impt.end()){
                    assert(nb==-1);
                    nb=i;
                }
                out[i]+=1<<b;
            }
        }

        pref.push_back(nb);
    }

    vector<int>ans;
    for(int i=0;i<n;i++){
        ans.push_back(out[i]);
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB n = 8
2 Correct 0 ms 500 KB n = 8
3 Correct 0 ms 348 KB n = 8
4 Correct 0 ms 348 KB n = 8
5 Correct 0 ms 348 KB n = 8
6 Correct 0 ms 344 KB n = 8
7 Correct 0 ms 344 KB n = 8
8 Correct 0 ms 344 KB n = 8
9 Correct 0 ms 348 KB n = 8
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 348 KB n = 8
12 Correct 0 ms 348 KB n = 8
13 Correct 0 ms 348 KB n = 8
14 Correct 1 ms 348 KB n = 8
15 Correct 0 ms 348 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 1 ms 348 KB n = 32
5 Correct 1 ms 344 KB n = 32
6 Correct 1 ms 348 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 1 ms 348 KB n = 32
10 Correct 0 ms 348 KB n = 32
11 Correct 0 ms 444 KB n = 32
12 Correct 1 ms 348 KB n = 32
13 Correct 0 ms 348 KB n = 32
14 Correct 1 ms 348 KB n = 32
15 Correct 0 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB n = 32
2 Correct 0 ms 348 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 1 ms 600 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 0 ms 444 KB n = 32
9 Correct 0 ms 348 KB n = 32
10 Correct 0 ms 348 KB n = 32
11 Correct 0 ms 348 KB n = 32
12 Correct 0 ms 600 KB n = 32
13 Correct 0 ms 348 KB n = 32
14 Correct 0 ms 348 KB n = 32
15 Correct 0 ms 348 KB n = 32
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB n = 128
2 Correct 2 ms 696 KB n = 128
3 Correct 1 ms 604 KB n = 128
4 Correct 1 ms 604 KB n = 128
5 Correct 1 ms 604 KB n = 128
6 Correct 1 ms 604 KB n = 128
7 Correct 1 ms 604 KB n = 128
8 Correct 1 ms 604 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 1 ms 604 KB n = 128
11 Correct 1 ms 604 KB n = 128
12 Correct 1 ms 600 KB n = 128
13 Correct 1 ms 600 KB n = 128
14 Correct 1 ms 444 KB n = 128
15 Correct 1 ms 856 KB n = 128
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 616 KB grader returned WA
2 Halted 0 ms 0 KB -