답안 #29727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29727 2017-07-20T11:38:23 Z PrOAhMeT 질문 (CEOI14_question_grader) C++14
0 / 100
7000 ms 27492 KB
#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;

static int cnt=5324;
static int a[1000];

int encode (int n, int x, int y) {

	//cout<<"hi "<<n<<" "<<x<<" "<<y<<endl;
	if(cnt%20==0||cnt==5324) {
	srand(cnt+123451);
	vector<int> v;
 	for(int i=1;i<=n;++i)
 		v.pb(i);
 	random_shuffle(v.begin(),v.end());
	for(int i=0;i<n;++i)
		a[v[i]]=i;
	}
	int c=1;
	++cnt;
	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;

static int cnt2=5324;
static int aa[1000];

int decode (int n, int q, int h) {

	//cout<<"out "<<n<<" "<<q<<" "<<h<<endl;
	if(cnt2%20==0||cnt2==5324) {
	srand(cnt2+123451);
	vector<int> v;
 	for(int i=1;i<=n;++i)
 		v.pb(i);
 	random_shuffle(v.begin(),v.end());
	for(int i=0;i<n;++i)
		aa[v[i]]=i;
	}
	q=aa[q];
	int xx=(h-1)/2,yy=!(h&1);
	int k=(q&(1<<xx));
	++cnt2;
	if(k) k=1;
	if(k==yy) return 1;
	else return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 7000 ms 27492 KB Execution timed out
2 Runtime error 6945 ms 27492 KB Execution killed with signal 9 (could be triggered by violating memory limits)