제출 #631635

#제출 시각아이디문제언어결과실행 시간메모리
631635minhcoolGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #include "gap.h" //#define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; //const int N = ; const int oo = 1e18 + 7, mod = 1e9 + 7; const int N = 5e5 + 5; long long int findgap(int T, int N){ if(T == 1){ long long lstx = 0, lsty = 1e18, a, b; set<long long> se; for(int i = 1; i <= (N + 1) / 2; i++){ MinMax(lstx, lsty, &a, &b); if(a != -1) se.insert(a); if(b != -1) se.insert(b); lstx = a + 1, lsty = b - 1; } vector<long long> arr; for(auto it : se) arr.pb(it); long long answer = 0; for(int i = 1; i < arr.size(); i++){ answer = max(answer, arr[i] - arr[i - 1]); } return answer; } else{ long long mini, maxi; MinMax(0, 1e18, &mini, &maxi); long long gap = (maxi - mini - 1) / (N - 1);// exist a gap where no numbers in there => ans >= gap => same gap don't care long long le = mini + 1, answer = 0, lst = mini; while(le + gap <= maxi){ long long temp1, temp2; MinMax(le, le + gap - 1, &temp1, &temp2); le += gap; if(temp1 == -1) continue; answer = max(answer, temp1 - lst); lst = temp2; } if(le < maxi){ long long temp1, temp2; MinMax(le, maxi - 1, &temp1, &temp2); if(temp1 != -1){ answer = max(answer, temp1 - lst); lst = temp2; } } answer = max(answer, maxi - lst); return answer; } }

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

gap.cpp:19:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
gap.cpp: In function 'long long int findgap(int, int)':
gap.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i = 1; i < arr.size(); i++){
      |                        ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cctQacxk.o: in function `main':
grader.cpp:(.text.startup+0x1b7): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status