제출 #275726

#제출 시각아이디문제언어결과실행 시간메모리
275726hamerinUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms640 KiB
#include "messy.h" #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using i64 = long long; using d64 = long double; using pi = pair<int, int>; using pli = pair<i64, i64>; using ti = tuple<int, int, int>; using tli = tuple<i64, i64, i64>; #define iterall(cont) cont.begin(), cont.end() #define prec(n) setprecision(n) << fixed int N; void add(int s, int e) { if (s == e - 1) return; string str(N, '1'); for (int i = s; i < e; i++) { str[i] = '0'; } int m = (s + e) >> 1; for (int i = m; i < e; i++) { str[i] = '1'; add_element(str); str[i] = '0'; } add(s, m); add(m, e); } vector<int> per; void check(int s, int e) { int m = (s + e) >> 1; if (s == e - 1) return; if (e - s == N) { string str(N, '0'); for (int i = 0; i < N; i++) { str[i] = '1'; if (check_element(str)) per[i] = m; str[i] = '0'; } } else { string str(N, '1'); vector<int> tar; for (int i = 0; i < N; i++) { if (per[i] == s) tar.emplace_back(i); } for (auto i : tar) str[i] = '0'; for (int i = 0; i < e - s; i++) { str[tar[i]] = '1'; if (check_element(str)) per[tar[i]] = m; str[tar[i]] = '0'; } } check(s, m); check(m, e); } vector<int> restore_permutation(int n, int w, int r) { N = n; per.resize(N); add(0, n); compile_set(); check(0, n); return per; }
#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...