제출 #1091034

#제출 시각아이디문제언어결과실행 시간메모리
1091034NurislamGap (APIO16_gap)C++17
0 / 100
3063 ms2416 KiB

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#include "gap.h"
typedef long long ll;
vector<ll> a;
void solve1(ll l, ll r, int n){
	ll lf = 1, rf = 1;
	MinMax(l, r, &lf, &rf);
	cout << lf << ' ' << rf << '\n';
	if(lf == -1)return;
	a.pb(lf);
	if(lf != rf)a.pb(rf);
	if(lf == rf || a.size() >= n)return;
	l = lf + 1;
	r = rf - 1;
	if(l > r)return;
	ll len = sqrt(r-l)+1;
	ll last = l;
	while(last <= r){
		solve1(last, min(last + len, r), n);
		last += len + 1;
	}
}

long long findGap(int t, int n)
{
	
	solve1(0, 1e18, n);
	sort(all(a));
	ll ans = 1;
	for(int i = 1; i < a.size(); i++)
		ans = max(ans, a[i] - a[i-1]);
	
	return ans;
}




















컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'void solve1(ll, ll, int)':
gap.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  if(lf == rf || a.size() >= n)return;
      |                 ~~~~~~~~~^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i = 1; i < a.size(); i++)
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...