제출 #151799

#제출 시각아이디문제언어결과실행 시간메모리
151799qkxwsmUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
5 ms676 KiB
/* PROG: template LANG: C++11 _____ .' '. / 0 0 \ | ^ | | \ / | \ '---' / '._____.' */ #include <bits/stdc++.h> #include "messy.h" using namespace std; template<class T> void readi(T &x) { T input = 0; bool negative = false; char c = ' '; while (c < '-') { c = getchar(); } if (c == '-') { negative = true; c = getchar(); } while (c >= '0') { input = input * 10 + (c - '0'); c = getchar(); } if (negative) { input = -input; } x = input; } template<class T> void printi(T output) { if (output == 0) { putchar('0'); return; } if (output < 0) { putchar('-'); output = -output; } int aout[20]; int ilen = 0; while(output) { aout[ilen] = ((output % 10)); output /= 10; ilen++; } for (int i = ilen - 1; i >= 0; i--) { putchar(aout[i] + '0'); } return; } template<class T> void ckmin(T &a, T b) { a = min(a, b); } template<class T> void ckmax(T &a, T b) { a = max(a, b); } long long randomize(long long mod) { return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod; } #define MP make_pair #define PB push_back #define PF push_front #define LB lower_bound #define UB upper_bound #define fi first #define se second const long double PI = 4.0 * atan(1.0); const long double EPS = 1e-20; #define MAGIC 347 #define SINF 10007 #define CO 1000007 #define INF 1000000007 #define BIG 1000000931 #define LARGE 1696969696967ll #define GIANT 2564008813937411ll #define LLINF 2696969696969696969ll #define MAXN 128 long long normalize(long long x, long long mod = INF) { return (((x % mod) + mod) % mod); } typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef bitset<MAXN> bs; typedef vector<int> vi; int N; vector<int> ans; bs cur; string conv(bs b) { string t = ""; for (int i = 0; i < N; i++) { t += (b[i] + '0'); } return t; } void ins(bs b) { add_element(conv(b)); return; } bool chk(bs b) { return check_element(conv(b)); } void init(int L, int R) { if (L == R) { return; } cur.set(); for (int i = L; i <= R; i++) { cur[i] = 0; } int mid = (L + R)/2; for (int i = L; i <= mid; i++) { cur[i] = 1; ins(cur); cur[i] = 0; } init(L, mid); init(mid + 1, R); } void solve(int L, int R, vi pos) { if (L == R) { ans[pos[0]] = L; return; } cur.set(); vector<int> lt, rt; for (int x : pos) { cur[x] = 0; } for (int x : pos) { cur[x] = 1; if (chk(cur)) { lt.PB(x); } else { rt.PB(x); } cur[x] = 0; } int mid = (L + R)/2; solve(L, mid, lt); solve(mid + 1, R, rt); } vi restore_permutation(int n, int W, int R) { N = n; ans.resize(N); init(0, N - 1); compile_set(); vector<int> v; for (int i = 0; i < N; i++) { v.PB(i); } solve(0, N - 1, v); 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...