Submission #25244

# Submission time Handle Problem Language Result Execution time Memory
25244 2017-06-21T04:10:06 Z 김동현(#1058) Secret (JOI14_secret) C++14
0 / 100
636 ms 5196 KB
#include "secret.h"
#include <cstdio>

const int sz = 1024;
struct Seg{
	int dat[2 * sz], chn[2 * sz][10];
	void ini(int n, int a[]){
		for(int i = 0; i < n; i++) dat[i + sz] = chn[i + sz][0] = a[i];
		for(int i = sz - 1; i >= 1; i--){
			dat[i] = Secret(dat[2 * i], dat[2 * i + 1]);
			chn[i][0] = dat[i];
			int t = (i % 2 ? 2 * i - 1 : 2 * i + 2);
			for(int j = 1; t < 2 * sz; j++){
				if(i % 2) chn[i][j] = Secret(dat[t], chn[i][j - 1]);
				else chn[i][j] = Secret(chn[i][j - 1], dat[t]);
				t = (i % 2 ? 2 * t - 1: 2 * t + 2);
			}
		}
	}
	int get(int s, int e){
		//printf("// %d %d\n", s, e);
		int lc = 0, rc = 0, ln = -1, rn = -1;
		for(s += sz, e += sz; s <= e; s /= 2, e /= 2){
			if(s == e){
				return dat[s];
			}
			if(s % 2 == 1){ if(ln > 0) lc++; ln = s++; }
			if(e % 2 == 0){ if(rn > 0) rc++; rn = e--; }
		}
		//printf("%d %d %d %d\n", ln, lc, rn, rc);
		return Secret(chn[ln][lc], chn[rn][rc]);
	}
} S;

void Init(int N, int A[]) {
	S.ini(N, A);
}

int Query(int L, int R) {
	return S.get(L, R);
}
# Verdict Execution time Memory Grader output
1 Runtime error 169 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 169 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 173 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 589 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 589 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 619 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 636 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 606 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 609 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 593 ms 5196 KB Execution killed with signal 11 (could be triggered by violating memory limits)