제출 #1160396

#제출 시각아이디문제언어결과실행 시간메모리
1160396Doncho_BonbonchoGap (APIO16_gap)C++20
컴파일 에러
0 ms0 KiB
#include <algorithm>
#include <random>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

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

#ifndef LOCAL
#define cerr if(false) cerr
#endif

#define out( x ) #x << " = " << x << "  "
#define endl "\n"

template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }

typedef long long ll;
const ll mod = 1e9 +7;
const int MAX_N = 1e6 + 42;


long long findGap(int subtask, int n){

	std::vector< ll > a;
	ll mn = -1;
	ll mx = 1e18 + 2;
	while( (ll)a.size() < n ){
		MinMax( mn+1, mx-1, &mn, &mx );
		if( mn != mx ){
			a.push_back( mn );
			a.push_back( mx );
		}else a.push_back( mn );
	}

	std::sort( a.begin(), a.end() );

	for( auto j : a ) cerr << j << " ";
	cerr << endl;

	ll nas = -1;
	for( int i=0 ; i < n ; i++ ) chkmax( nas, a[i+1] - a[i] );

	cerr << out( nas ) << endl;
	return nas;
}

int main()
{
	FILE *in = stdin, *out = stdout;
	my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
	my_assert(1 <= subtask_num && subtask_num <= 2);
	my_assert(2 <= N && N <= 100000);
	for (int i=1;i<=N;i++) my_assert(1 == fscanf(in, "%lld", A+i));
	for (int i=1;i<N;i++) my_assert(A[i] < A[i+1]);
	fprintf(out, "%lld\n", findGap(subtask_num, N));
	fprintf(out, "%lld\n", call_count);
}

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

gap.cpp: In function 'int main()':
gap.cpp:54:44: error: 'subtask_num' was not declared in this scope
   54 |         my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
      |                                            ^~~~~~~~~~~
gap.cpp:54:58: error: 'N' was not declared in this scope
   54 |         my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
      |                                                          ^
gap.cpp:54:9: error: 'my_assert' was not declared in this scope; did you mean 'assert'?
   54 |         my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
      |         ^~~~~~~~~
      |         assert
gap.cpp:57:66: error: 'A' was not declared in this scope
   57 |         for (int i=1;i<=N;i++) my_assert(1 == fscanf(in, "%lld", A+i));
      |                                                                  ^
gap.cpp:58:41: error: 'A' was not declared in this scope
   58 |         for (int i=1;i<N;i++) my_assert(A[i] < A[i+1]);
      |                                         ^
gap.cpp:60:32: error: 'call_count' was not declared in this scope
   60 |         fprintf(out, "%lld\n", call_count);
      |                                ^~~~~~~~~~