Submission #430868

#TimeUsernameProblemLanguageResultExecution timeMemory
430868CollypsoUnscrambling a Messy Bug (IOI16_messy)C++17
49 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vt vector #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #pragma GCC optimize ("O3") #pragma GCC optimize ("O2") #define F first #define S second //#define endl '\n' //#define int long long using namespace std; void add_element(string x); bool check_element(string x); void compile_set(); vt<int> restore_permutation(int n, int w, int r) { { // INIT string s(n, '0'); s[0] = '1'; for(int i = 0; i < n; i++, s[i] = '1') add_element(s); compile_set(); } string cur(n, '0'); vt<int> ans(n, n - 1); for(int ones = 1; ones < n; ones++) { srand(time(NULL)); string tmp = cur; vt<int> used(n); int used_cnt = ones - 1; bool found = 0; while(true) { if (used_cnt == n - 1) break; int i = rand() % n; if (tmp[i] == '1' || used[i]) continue; tmp[i] = '1'; used[i] = 1; if (check_element(tmp)) { found = 1; ans[i] = ones - 1; break; } tmp[i] = '0'; used_cnt++; } if (!found) { for(int i = 0; i < n; i++) { if (tmp[i] == '1' || used[i]) continue; tmp[i] = '1'; ans[i] = ones - 1; break; } } /* for(int i = 0; i < n; i++) { if (tmp[i] == '1') continue; tmp[i] = '1'; bool exist = check_element(tmp); //cout << tmp << " " << exist << endl; if (exist) { ans[i] = ones - 1; break; } tmp[i] = '0'; } */ cur = tmp; //cout << endl; } 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...