Submission #650409

#TimeUsernameProblemLanguageResultExecution timeMemory
650409rafatoaUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #pragma GCC optimize ("Ofast") #define double ld const int inf = 2e9; const int INF = 4e18; const int mod = 1e9+7; #define F first #define S second #define vi vector<int> #define vvi vector<vi> #define pi pair<int, int> #define vpi vector<pi> #define vb vector<bool> #define vvb vector<vb> #define pb push_back #define read(a) for(auto &x:a) cin >> x; #define print(a) for(auto x:a) cout << x << " "; cout << "\n"; #define rs resize #define as assign #define vc vector<char> #define vvc vector<vc> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define ppb pop_back #define MP make_pair // #define int ll void add_element(string x); void compile_set(); bool check_element(string x); vi restore_permutation(int n, int w, int r){ vi p(n); function<void(int, int)> add = [&](int l, int r){ if(l == r) return; for(int j=l; j<l+(r-l+1)/2; j++){ string s; for(int i=0; i<n; i++) if(i < l || i > r || i == j) s += '1'; else s += '0'; add_element(s); } add(l, l+(r-l+1)/2-1); add(l+(r-l+1)/2, r); }; add(0, n-1); compile_set(); function<void(int, int, vi)> solve = [&](int l, int r, vi v){ if(l == r){ p[v[0]] = l; return; } vi a, b; for(auto &x:v){ string s; for(int i=0; i<n; i++){ if(i != x && binary_search(all(v), i)) s += '0'; else s += '1'; } if(check_element(s)) a.pb(x); else b.pb(x); } solve(l, l+(r-l+1)/2-1, a); solve(l+(r-l+1)/2, r, b); }; vi v(n); iota(all(v), 0); solve(0, n-1, v); return p; } /*stolen stuff you should look for * int overflow, array bounds * special cases (n=1?) * READ CONSTRAINTS * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */

Compilation message (stderr)

messy.cpp:9:17: warning: overflow in conversion from 'double' to 'int' changes value from '4.0e+18' to '2147483647' [-Woverflow]
    9 | const int INF = 4e18;
      |                 ^~~~
#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...