Submission #638382

#TimeUsernameProblemLanguageResultExecution timeMemory
638382ghostwriterUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms504 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #include "grader.cpp" #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ vi ans, ans1; void add(int n, int l, int r) { if (l == r) return; str s(n, '1'); FOR(i, l, r) s[i] = '0'; int m = l + (r - l + 1) / 2 - 1; FOR(i, l, m) { str cur = s; cur[i] = '1'; add_element(cur); } add(n, l, m); add(n, m + 1, r); } void cal(int l, int r, str s) { if (l == r) { FOR(i, 0, sz(s) - 1) if (s[i] == '0') ans[l] = i; return; } vi a1, a2; FOR(i, 0, sz(s) - 1) { if (s[i] == '1') continue; str cur = s; cur[i] = '1'; if (check_element(cur)) a2.pb(i); else a1.pb(i); } str s1 = s, s2 = s; EACH(i, a1) s1[i] = '1'; EACH(i, a2) s2[i] = '1'; int mid = l + (r - l + 1) / 2 - 1; cal(l, mid, s1); cal(mid + 1, r, s2); } std::vector<int> restore_permutation(int n, int w, int r) { add(n, 0, n - 1); compile_set(); str s(n, '0'); ans.resize(n, 0); ans1.resize(n, 0); cal(0, n - 1, s); FOR(i, 0, n - 1) ans1[ans[i]] = i; return ans1; } /* 4 16 16 2 1 3 0 */

Compilation message (stderr)

messy.cpp: In function 'void add(int, int, int)':
messy.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
messy.cpp:43:5: note: in expansion of macro 'FOR'
   43 |     FOR(i, l, r) s[i] = '0';
      |     ^~~
messy.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
messy.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(i, l, m) {
      |     ^~~
messy.cpp: In function 'void cal(int, int, str)':
messy.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
messy.cpp:55:9: note: in expansion of macro 'FOR'
   55 |         FOR(i, 0, sz(s) - 1)
      |         ^~~
messy.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
messy.cpp:61:5: note: in expansion of macro 'FOR'
   61 |     FOR(i, 0, sz(s) - 1) {
      |     ^~~
messy.cpp:29:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   29 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
messy.cpp:69:5: note: in expansion of macro 'EACH'
   69 |     EACH(i, a1) s1[i] = '1';
      |     ^~~~
messy.cpp:29:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   29 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
messy.cpp:70:5: note: in expansion of macro 'EACH'
   70 |     EACH(i, a2) s2[i] = '1';
      |     ^~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:27:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   27 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
messy.cpp:82:5: note: in expansion of macro 'FOR'
   82 |     FOR(i, 0, n - 1) ans1[ans[i]] = i;
      |     ^~~
#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...