제출 #29659

#제출 시각아이디문제언어결과실행 시간메모리
29659PrOAhMeT질문 (CEOI14_question_grader)C++14
0 / 100
7000 ms25460 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; int encode (int n, int x, int y) { //cout<<"hi "<<n<<" "<<x<<" "<<y<<endl; srand(1203); vector<int> v; for(int i=1;i<=n;++i) v.pb(i); random_shuffle(v.begin(),v.end()); int a[n+1]; for(int i=0;i<n;++i) a[v[i]]=i; int c=1; for(int i=0;;++i) { if((a[x]&(1<<i))!=(a[y]&(1<<i))) { return c+((a[x]&(1<<i))?1:0); } c+=2; } }
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; int decode (int n, int q, int h) { //cout<<"out "<<n<<" "<<q<<" "<<h<<endl; srand(1203); vector<int> v; for(int i=1;i<=n;++i) v.pb(i); random_shuffle(v.begin(),v.end()); int a[n+1]; for(int i=0;i<n;++i) a[v[i]]=i; q=a[q]; int xx=(h-1)/2,yy=!(h&1); int k=(q&(1<<xx)); if(k) k=1; if(k==yy) return 1; else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...