Submission #42637

# Submission time Handle Problem Language Result Execution time Memory
42637 2018-03-01T16:05:58 Z fefe Gap (APIO16_gap) C++14
0 / 100
105 ms 3824 KB
#include "gap.h"
#include<stack>
#define f MinMax
#define max(x,y) ((x)>(y)?(x):(y))
using namespace std;
long long findGap(int T, int N)
{
	long long s,e,ps,pe,maxx=0,x,y;
	if(T==1){
		f(0,(1LL<<62),&ps,&pe);
		N-=2;
		while(N>=2){
			f(ps+1,pe-1,&s,&e);
			N-=2;
			maxx=max(maxx,max(s-ps,pe-e));
			ps=s;pe=e;
		}
		return max(maxx,pe-ps);
	}
	f(0,(1LL<<62),&ps,&pe);
	x=0;
	struct node{
		long long x,s,e;
	};
	stack<node> st;
	node p;
	while(ps!=pe){
		y=x;
		while(1){
			f(ps+1,ps+(1LL<<y),&s,&e);
			if(s!=-1)	break;
			y++;
		}
		if(x!=y)	while(!st.empty())	st.pop();
		p.x=ps;p.s=s;p.e=e;
		st.push(p);
		x=y;
		ps=e;
	}
	if(x==0)	return 1;
	while(!st.empty()){
		p=st.top();st.pop();
		f(p.x+1,p.x+(1LL<<(x-1)),&s,&e);
		if(s!=-1)	continue;
		maxx=max(maxx,p.s-p.x);
	}
	return maxx;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Incorrect 1 ms 424 KB Output isn't correct
4 Correct 1 ms 496 KB Output is correct
5 Incorrect 1 ms 568 KB Output isn't correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 1 ms 584 KB Output is correct
8 Correct 2 ms 712 KB Output is correct
9 Correct 1 ms 712 KB Output is correct
10 Correct 1 ms 712 KB Output is correct
11 Correct 2 ms 712 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 740 KB Output is correct
16 Correct 15 ms 748 KB Output is correct
17 Correct 15 ms 748 KB Output is correct
18 Correct 15 ms 748 KB Output is correct
19 Correct 18 ms 748 KB Output is correct
20 Correct 11 ms 748 KB Output is correct
21 Correct 55 ms 1388 KB Output is correct
22 Correct 54 ms 1388 KB Output is correct
23 Correct 54 ms 1392 KB Output is correct
24 Correct 57 ms 1500 KB Output is correct
25 Correct 46 ms 1516 KB Output is correct
26 Correct 56 ms 1516 KB Output is correct
27 Correct 60 ms 1516 KB Output is correct
28 Correct 62 ms 1516 KB Output is correct
29 Correct 57 ms 1516 KB Output is correct
30 Correct 40 ms 1516 KB Output is correct
31 Correct 2 ms 1516 KB Output is correct
32 Correct 2 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 1516 KB Partially correct
2 Partially correct 1 ms 1516 KB Partially correct
3 Partially correct 1 ms 1516 KB Partially correct
4 Partially correct 1 ms 1516 KB Partially correct
5 Partially correct 1 ms 1516 KB Partially correct
6 Partially correct 1 ms 1516 KB Partially correct
7 Incorrect 1 ms 1516 KB Output isn't correct
8 Partially correct 2 ms 1516 KB Partially correct
9 Partially correct 1 ms 1516 KB Partially correct
10 Correct 1 ms 1516 KB Output is correct
11 Correct 2 ms 1516 KB Output is correct
12 Correct 3 ms 1516 KB Output is correct
13 Correct 2 ms 1516 KB Output is correct
14 Incorrect 2 ms 1516 KB Output isn't correct
15 Partially correct 3 ms 1516 KB Partially correct
16 Incorrect 11 ms 1516 KB Output isn't correct
17 Correct 12 ms 1516 KB Output is correct
18 Correct 13 ms 1516 KB Output is correct
19 Correct 15 ms 1516 KB Output is correct
20 Correct 8 ms 1516 KB Output is correct
21 Correct 40 ms 1516 KB Output is correct
22 Correct 42 ms 1516 KB Output is correct
23 Correct 39 ms 1516 KB Output is correct
24 Correct 34 ms 1516 KB Output is correct
25 Partially correct 105 ms 3824 KB Partially correct
26 Correct 36 ms 3824 KB Output is correct
27 Correct 49 ms 3824 KB Output is correct
28 Correct 43 ms 3824 KB Output is correct
29 Correct 46 ms 3824 KB Output is correct
30 Correct 32 ms 3824 KB Output is correct
31 Partially correct 1 ms 3824 KB Partially correct
32 Correct 1 ms 3824 KB Output is correct