답안 #320698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320698 2020-11-09T14:30:33 Z NhatMinh0208 Gap (APIO16_gap) C++14
100 / 100
73 ms 3288 KB
/*
khoi orz, go check out his algo
-normie-
Tested with library-checker.
*/
#include <gap.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define FILE_IN "birds.inp"
#define FILE_OUT "birds.out"
#define prev prv
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 320
#define p1 first
#define p2 second.first
#define p3 second.second
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
typedef long long ll;
#define pi 3.1415926535897
//------START-----------//
ll n,m,i,j,k,u,v,t,t1,a,b,l,r,ress=0;
set<ll> se;
vector<ll> lis;
//------END-----------//
ll findGap (int T, int N)
{
	n=N,t=T;
	if (t==2)
	{
		MinMax(0,1e18,&l,&r);
		lis.push_back(l);
		lis.push_back(r);
		u=l;
		for (i=0;i<n-1;i++)  
		{
		
		if (i<(r-l+1)%(n-1)) v=u+((r-l+1)/(n-1)+1); else v=u+((r-l+1)/(n-1));
		MinMax(u+1,v,&a,&b); 
		if (a!=-1) {
			lis.push_back(a);
			lis.push_back(b);
		}
		u=v;
		
		}
		sort(lis.begin(),lis.end());
		ress=0;
		for (i=0;i<lis.size()-1;i++) ress=max(ress,lis[i+1]-lis[i]);
		return ress;
	}
	else
	{
		l=0,r=1e18;
		for (i=0;i<(n+1)/2;i++) 
		{
			MinMax(l,r,&a,&b);
			lis.push_back(a);
			lis.push_back(b);
			l=a+1;
			r=b-1;
		}
		
		sort(lis.begin(),lis.end());
		ress=0;
		for (i=0;i<lis.size()-1;i++) ress=max(ress,lis[i+1]-lis[i]);
		return ress;
	}
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:65:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for (i=0;i<lis.size()-1;i++) ress=max(ress,lis[i+1]-lis[i]);
      |            ~^~~~~~~~~~~~~
gap.cpp:82:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |   for (i=0;i<lis.size()-1;i++) ress=max(ress,lis[i+1]-lis[i]);
      |            ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 876 KB Output is correct
17 Correct 12 ms 876 KB Output is correct
18 Correct 13 ms 876 KB Output is correct
19 Correct 13 ms 876 KB Output is correct
20 Correct 10 ms 876 KB Output is correct
21 Correct 50 ms 2268 KB Output is correct
22 Correct 62 ms 2272 KB Output is correct
23 Correct 48 ms 2472 KB Output is correct
24 Correct 51 ms 2268 KB Output is correct
25 Correct 45 ms 2308 KB Output is correct
26 Correct 51 ms 2272 KB Output is correct
27 Correct 53 ms 2288 KB Output is correct
28 Correct 50 ms 2268 KB Output is correct
29 Correct 51 ms 2468 KB Output is correct
30 Correct 40 ms 2268 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 16 ms 1004 KB Output is correct
17 Correct 18 ms 1132 KB Output is correct
18 Correct 17 ms 876 KB Output is correct
19 Correct 17 ms 1148 KB Output is correct
20 Correct 7 ms 640 KB Output is correct
21 Correct 66 ms 2264 KB Output is correct
22 Correct 72 ms 2268 KB Output is correct
23 Correct 66 ms 2360 KB Output is correct
24 Correct 73 ms 2268 KB Output is correct
25 Correct 62 ms 3288 KB Output is correct
26 Correct 64 ms 2432 KB Output is correct
27 Correct 66 ms 2356 KB Output is correct
28 Correct 66 ms 2300 KB Output is correct
29 Correct 65 ms 2268 KB Output is correct
30 Correct 35 ms 1524 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct