Submission #26405

#TimeUsernameProblemLanguageResultExecution timeMemory
26405zscoderQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++14
100 / 100
1668 ms27480 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<ll,ll> ii; typedef vector<ll> vi; typedef long double ld; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<ll>::iterator sit; typedef map<ll,ll>::iterator mit; const int C = 12; vector<int> vec; static void gen() { int s = (1 << 6) - 1; while (!(s & 1 << 12)) { // do stuff with s vec.pb(s); int lo = s & ~(s - 1); // lowest one bit int lz = (s + lo) & ~s; // lowest zero bit above lo s |= lz; // add lz to the set s &= ~(lz - 1); // reset bits below lz s |= (lz / lo / 2) - 1; // put back right number of bits at end } } int encode (int n, int x, int y) { if(vec.empty()) gen(); int s1 = vec[x]; int s2 = vec[y]; for(int i = 0; i < C; i++) { if((s1&(1<<i)) && !(s2&(1<<i))) return i+1; } return -1; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<ll,ll> ii; typedef vector<ll> vi; typedef long double ld; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<ll>::iterator sit; typedef map<ll,ll>::iterator mit; const int C = 12; vector<int> vec2; static void gen() { int s = (1 << 6) - 1; while (!(s & 1 << 12)) { // do stuff with s vec2.pb(s); int lo = s & ~(s - 1); // lowest one bit int lz = (s + lo) & ~s; // lowest zero bit above lo s |= lz; // add lz to the set s &= ~(lz - 1); // reset bits below lz s |= (lz / lo / 2) - 1; // put back right number of bits at end } } int decode (int n, int q, int h) { if(vec2.empty()) gen(); h--; int tmp = vec2[q]; if(tmp&(1<<h)) return 1; else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...