제출 #396232

#제출 시각아이디문제언어결과실행 시간메모리
396232giorgikobGap (APIO16_gap)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; //#include "game.h" //#include "gap.h" static void my_assert(int k){ if (!k) exit(1); } static int subtask_num, N; static long long A[100001]; static long long call_count; long long findGap(int, int); void MinMax(long long s, long long t, long long *mn, long long *mx) { int lo = 1, hi = N, left = N+1, right = 0; my_assert(s <= t && mn != NULL && mx != NULL); while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] >= s) hi = mid - 1, left = mid; else lo = mid + 1; } lo = 1, hi = N; while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] <= t) lo = mid + 1, right = mid; else hi = mid - 1; } if (left > right) *mn = *mx = -1; else{ *mn = A[left]; *mx = A[right]; } if (subtask_num == 1) call_count++; else if (subtask_num == 2) call_count += right-left+2; } ll answer = 0; long long findGap(int T, int N) { ll l = -1, r = 1e18; r++; ll cnt = 0; int calls = 0; ll len = -1; if(T == 1){ while(true){ ll new_l,new_r; if(len != -1){ if((r-l) < len/N) break; } cnt++; if(answer >= r-l) break; if(cnt > (N+1)/2){ if(l != r){ answer = max(answer,r-l); } break; } if(l+1 > r-1){ if(l == r) break; answer = max(answer,r-l); break; } MinMax(l+1,r-1,&new_l,&new_r); calls++; if(new_l == -1){ answer = max(answer,r-l); break; } else { if(cnt > 1)answer = max(answer, max(new_l-l,r-new_r)); else len = new_r-new_l; l = new_l; r = new_r; } } } else { ll last = -1; MinMax(0,1e18,&l,&r); ll k = (r-l+1)/N; if((r-l+1)%N) k++; if(r-l+1 == N){ return N; } assert(k != 1); for(ll i = l; i <= r; i += k){ ll a,b; ll askl = i; if(i == l) askl = l+1; MinMax(askl,min(i+k-1,r),&a,&b); if(a == -1){ continue; } //answer = max(answer,b-a); if(last != -1){ answer = max(answer,a-last); } last = b; } } return answer; } 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); //assert(call_count <= (N+1)/2); }

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

/tmp/ccvZNLLx.o: In function `MinMax(long long, long long, long long*, long long*)':
grader.cpp:(.text+0x0): multiple definition of `MinMax(long long, long long, long long*, long long*)'
/tmp/cclcvvMf.o:gap.cpp:(.text+0x0): first defined here
/tmp/ccvZNLLx.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cclcvvMf.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status