답안 #1015286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015286 2024-07-06T08:24:42 Z vjudge1 Gap (APIO16_gap) C++17
0 / 100
37 ms 1240 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

long long findGap(signed t,signed n)
{
	if (t==2 && n>60)
	{
		ll mn1,mx1;
		MinMax(0,(ll)1e18,&mn1,&mx1);
		ll st,mn,mx,ans=0;
		for (int i=0;i<=60;i++)
		{
			MinMax(mn1+1,mn1+(1LL<<i),&mn,&mx);
			if (mn!=-1)
			{
				ans=mn-mn1;
				st=mx;
				break;
			}
		}
		while (st<mx1)
		{
			MinMax(st+1,st+ans,&mn,&mx);
			if (mn!=-1)
				st=mx;
			else
			{
				ll val=ans*2;
				while (1)
				{
					MinMax(st+1,st+val,&mn,&mx);
					if (mn!=-1)
					{
						ans=mn-st;
						st=mx;
						break;
					}
					val*=2;
				}
			}
		}
		return ans;
	}
	else
	{
		long long lim1=0,lim2=1e18;
		long long mn,mx,mn1,mx1;
		MinMax(lim1,lim2,&mn1,&mx1);
		if (n==2)
			return mx1-mn1;
		MinMax(mn1+1,mx1-1,&mn,&mx);
		ll ans = max(mn-mn1,mx1-mx);
		while (mn+ans*2<=mx)
		{
			MinMax(mn+ans,mx-ans,&mn1,&mx1);
			if (mn1==-1)
				break;
			ans=max(ans,max(mn1-mn,mx-mx1));
			mn=mn1,mx=mx1;
		}
		while (mn+ans<mx)
		{
			MinMax(mn+1,mx-1,&mn1,&mx1);
			if (mn1==-1)
			{
				ans=max(ans,mx-mn);
				break;
			}
			ans=max(ans,max(mn1-mn,mx-mx1));
			mn=mn1,mx=mx1;
		}
		
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:10: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |       ans=mn-st;
      |       ~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Incorrect 0 ms 368 KB Output isn't correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB Output isn't correct
12 Incorrect 1 ms 344 KB Output isn't correct
13 Incorrect 1 ms 344 KB Output isn't correct
14 Incorrect 1 ms 456 KB Output isn't correct
15 Correct 0 ms 344 KB Output is correct
16 Incorrect 4 ms 600 KB Output isn't correct
17 Incorrect 4 ms 600 KB Output isn't correct
18 Incorrect 7 ms 600 KB Output isn't correct
19 Incorrect 7 ms 600 KB Output isn't correct
20 Correct 7 ms 656 KB Output is correct
21 Incorrect 24 ms 1112 KB Output isn't correct
22 Incorrect 13 ms 1176 KB Output isn't correct
23 Incorrect 24 ms 992 KB Output isn't correct
24 Incorrect 21 ms 1112 KB Output isn't correct
25 Correct 24 ms 1112 KB Output is correct
26 Incorrect 24 ms 1160 KB Output isn't correct
27 Incorrect 14 ms 1112 KB Output isn't correct
28 Incorrect 22 ms 1112 KB Output isn't correct
29 Incorrect 13 ms 1112 KB Output isn't correct
30 Correct 18 ms 1240 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Partially correct 1 ms 344 KB Partially correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Partially correct 1 ms 344 KB Partially correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Partially correct 1 ms 344 KB Partially correct
16 Correct 6 ms 552 KB Output is correct
17 Correct 8 ms 624 KB Output is correct
18 Correct 6 ms 600 KB Output is correct
19 Correct 5 ms 564 KB Output is correct
20 Correct 5 ms 648 KB Output is correct
21 Correct 29 ms 1240 KB Output is correct
22 Correct 24 ms 1000 KB Output is correct
23 Correct 23 ms 1056 KB Output is correct
24 Correct 24 ms 1112 KB Output is correct
25 Partially correct 37 ms 1216 KB Partially correct
26 Correct 24 ms 1000 KB Output is correct
27 Correct 33 ms 1068 KB Output is correct
28 Correct 26 ms 1216 KB Output is correct
29 Correct 19 ms 1140 KB Output is correct
30 Correct 22 ms 1112 KB Output is correct
31 Partially correct 0 ms 344 KB Partially correct
32 Correct 1 ms 344 KB Output is correct