Submission #42685

# Submission time Handle Problem Language Result Execution time Memory
42685 2018-03-02T15:55:03 Z fefe Gap (APIO16_gap) C++14
42.6461 / 100
113 ms 3736 KB
#include "gap.h"
#include<stack>
#include<stdio.h>
#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;
		}
		if(N==1){
			f(ps+1,pe-1,&s,&e);
			return max(maxx,max(s-ps,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-1;
		while(1){
			if(y==-1){y++;continue;}
			f(ps+1,ps+(1LL<<(y)),&s,&e);
			if(s!=-1)	break;
			y++;
		}
		if(x>y){ps=e;continue;}
		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();
		maxx=max(maxx,p.s-p.x);
	}
	return maxx;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 1 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 1 ms 552 KB Output is correct
8 Correct 1 ms 552 KB Output is correct
9 Correct 2 ms 552 KB Output is correct
10 Correct 1 ms 552 KB Output is correct
11 Correct 2 ms 552 KB Output is correct
12 Correct 2 ms 552 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 21 ms 732 KB Output is correct
17 Correct 14 ms 736 KB Output is correct
18 Correct 15 ms 736 KB Output is correct
19 Correct 15 ms 736 KB Output is correct
20 Correct 11 ms 736 KB Output is correct
21 Correct 52 ms 1372 KB Output is correct
22 Correct 54 ms 1388 KB Output is correct
23 Correct 52 ms 1388 KB Output is correct
24 Correct 54 ms 1516 KB Output is correct
25 Correct 46 ms 1516 KB Output is correct
26 Correct 55 ms 1516 KB Output is correct
27 Correct 57 ms 1516 KB Output is correct
28 Correct 60 ms 1516 KB Output is correct
29 Correct 54 ms 1516 KB Output is correct
30 Correct 44 ms 1516 KB Output is correct
31 Correct 1 ms 1516 KB Output is correct
32 Correct 2 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 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 Correct 1 ms 1516 KB Output is correct
8 Correct 1 ms 1516 KB Output is correct
9 Partially correct 2 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 2 ms 1516 KB Output is correct
13 Correct 2 ms 1516 KB Output is correct
14 Correct 2 ms 1516 KB Output is correct
15 Partially correct 3 ms 1516 KB Partially correct
16 Correct 18 ms 1516 KB Output is correct
17 Correct 12 ms 1516 KB Output is correct
18 Correct 18 ms 1516 KB Output is correct
19 Correct 11 ms 1516 KB Output is correct
20 Correct 8 ms 1516 KB Output is correct
21 Correct 44 ms 1516 KB Output is correct
22 Correct 39 ms 1516 KB Output is correct
23 Correct 39 ms 1516 KB Output is correct
24 Correct 37 ms 1516 KB Output is correct
25 Partially correct 113 ms 3736 KB Partially correct
26 Correct 46 ms 3736 KB Output is correct
27 Correct 39 ms 3736 KB Output is correct
28 Correct 49 ms 3736 KB Output is correct
29 Correct 39 ms 3736 KB Output is correct
30 Correct 31 ms 3736 KB Output is correct
31 Partially correct 1 ms 3736 KB Partially correct
32 Correct 1 ms 3736 KB Output is correct