답안 #499856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499856 2021-12-29T19:45:01 Z robell Gap (APIO16_gap) C++14
100 / 100
55 ms 1960 KB
/*
Problem: 
Problem Link: 
Notes: 
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include "gap.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define f first
#define s second
int mod=1e9+7;
inline void rv(int &n){
    n=0;int m=1;char c=getchar();if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(ll &n){
    n=0;int m=1;char c=getchar();if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(double &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){double p = 0.1;c=getchar();for (;c>47 && c<58;c=getchar()){n+=((c-48)*p);p/=10;}}
    n*=m;
}
inline void rv(float &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){double p = 0.1;c=getchar();for (;c>47 && c<58;c=getchar()){n+=((c-48)*p);p/=10;}}
    n*=m;
}
inline void rv(string &w){w="";char c=getchar();while (c!=' '&&c!='\n'&&c!=EOF){w+=c;c=getchar();}}
inline void rv(char &c){c=getchar();}
template<typename T, typename ...Types>
void rv(T &n, Types&&... args){rv(n);rv(args...);}
void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void setIO(string f){
	freopen((f+".in").c_str(),"r",stdin);
	freopen((f+".out").c_str(),"w",stdout);
	setIO();
}
ll a[100000],j=0;
ll findGap(int T, int N){
    if (T==1) {
		ll l=1,r=1e18;
		ll mn,mx;
		vector<ll> v;
		for (ll i=0;i<(N+1)/2;i++) {
			MinMax(l,r,&mn,&mx);
			a[j++] = mn;
			a[j++] = mx;
			l=mn+1,r=mx-1;
		}
		sort(a,a+N);
		ll ans=0;
		for (ll i=0;i<N-1;i++)ans=max(ans,a[i+1]-a[i]);
		return ans;
	} else {
		ll mn, mx;
		MinMax(1,1e18,&mn,&mx);
		ll step=(mx-mn+N-2)/(N-1);
		ll ans=step,x,y,l=mn,i;
		for (i=mn;i+step<mx;i+=step+1){
			MinMax(i,i+step,&x,&y);
			if(x!=-1){
				ans=max(ans,x-l);
				l=y;
			}
		}
		MinMax(i, mx, &x, &y);
		if (x!=-1)ans=max(ans,x-l);
		return ans;
	}
}

Compilation message

gap.cpp: In function 'void setIO(std::string)':
gap.cpp:53:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |  freopen((f+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp:54:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |  freopen((f+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 9 ms 680 KB Output is correct
17 Correct 10 ms 584 KB Output is correct
18 Correct 10 ms 676 KB Output is correct
19 Correct 15 ms 596 KB Output is correct
20 Correct 12 ms 584 KB Output is correct
21 Correct 40 ms 1856 KB Output is correct
22 Correct 41 ms 1776 KB Output is correct
23 Correct 36 ms 1840 KB Output is correct
24 Correct 47 ms 1852 KB Output is correct
25 Correct 34 ms 1824 KB Output is correct
26 Correct 39 ms 1960 KB Output is correct
27 Correct 38 ms 1820 KB Output is correct
28 Correct 38 ms 1860 KB Output is correct
29 Correct 38 ms 1736 KB Output is correct
30 Correct 31 ms 1864 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 13 ms 468 KB Output is correct
17 Correct 12 ms 456 KB Output is correct
18 Correct 11 ms 512 KB Output is correct
19 Correct 13 ms 456 KB Output is correct
20 Correct 6 ms 456 KB Output is correct
21 Correct 48 ms 1040 KB Output is correct
22 Correct 48 ms 996 KB Output is correct
23 Correct 54 ms 1056 KB Output is correct
24 Correct 55 ms 1044 KB Output is correct
25 Correct 47 ms 1028 KB Output is correct
26 Correct 48 ms 1076 KB Output is correct
27 Correct 48 ms 1076 KB Output is correct
28 Correct 55 ms 1080 KB Output is correct
29 Correct 50 ms 1096 KB Output is correct
30 Correct 31 ms 1128 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct