답안 #40763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40763 2018-02-08T05:48:55 Z ssnsarang2023 Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"

typedef long long ll;

ll findGap(int _t, int _n) {
	ll n = _n;
	ll mn = 1, mx = (ll)1e18;
	MinMax(mn, mx, mn, mx);
	ll d = (mx - mn) / n, mod = (mx - mn) % n, pre = mn;
	ll pstep = mn, step = mn + d + - 1 + mod, gap = 0;
	while (1) {
		ll mntmp = -1, mxtmp = -1;
		if (pstep <= min(mx - 1, step)) MinMax(pstep + 1, min(mx - 1, step), mntmp, mxtmp);
		if (step >= mx) {
			if (mxtmp != -1) gap = max(gap, mx - mxtmp);
			else gap = max(gap, mx - pre);
		} else if (mntmp != -1) gap = max(gap, mntmp - pre);
		pre = mxtmp, pstep = step, step += d;
	}
	return gap;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:9:23: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
  MinMax(mn, mx, mn, mx);
                       ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^
gap.cpp:9:23: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
  MinMax(mn, mx, mn, mx);
                       ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^
gap.cpp:14:32: error: 'min' was not declared in this scope
   if (pstep <= min(mx - 1, step)) MinMax(pstep + 1, min(mx - 1, step), mntmp, mxtmp);
                                ^
gap.cpp:14:32: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3451:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:16:46: error: 'max' was not declared in this scope
    if (mxtmp != -1) gap = max(gap, mx - mxtmp);
                                              ^
gap.cpp:16:46: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:17:32: error: 'max' was not declared in this scope
    else gap = max(gap, mx - pre);
                                ^
gap.cpp:17:32: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:18:53: error: 'max' was not declared in this scope
   } else if (mntmp != -1) gap = max(gap, mntmp - pre);
                                                     ^
gap.cpp:18:53: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^