제출 #631631

#제출 시각아이디문제언어결과실행 시간메모리
631631minhcoolGap (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){ int 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> a; for(auto it : se) a.pb(it); long long answer = 0; for(int i = 1; i < a.size(); i++){ answer = max(answer, a[i] - a[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) continue; 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:26:30: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   26 |         int lstx = 0, lsty = 1e18, a, b;
      |                              ^~~~
gap.cpp:28:30: error: 'n' was not declared in this scope
   28 |         for(int i = 1; i <= (n + 1) / 2; i++){
      |                              ^
gap.cpp:29:32: error: cannot convert 'int*' to 'long long int*'
   29 |             MinMax(lstx, lsty, &a, &b);
      |                                ^~
      |                                |
      |                                int*
In file included from gap.cpp:4:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:34:27: error: conflicting declaration 'std::vector<long long int> a'
   34 |         vector<long long> a;
      |                           ^
gap.cpp:26:36: note: previous declaration as 'int a'
   26 |         int lstx = 0, lsty = 1e18, a, b;
      |                                    ^
gap.cpp:8:12: error: request for member 'push_back' in 'a', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
gap.cpp:35:29: note: in expansion of macro 'pb'
   35 |         for(auto it : se) a.pb(it);
      |                             ^~
gap.cpp:37:30: error: request for member 'size' in 'a', which is of non-class type 'int'
   37 |         for(int i = 1; i < a.size(); i++){
      |                              ^~~~
gap.cpp:38:35: error: invalid types 'int[int]' for array subscript
   38 |             answer = max(answer, a[i] - a[i - 1]);
      |                                   ^
gap.cpp:38:42: error: invalid types 'int[int]' for array subscript
   38 |             answer = max(answer, a[i] - a[i - 1]);
      |                                          ^
gap.cpp:44:25: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   44 |         MinMax(0, 1e18, mini, maxi);
      |                         ^~~~
      |                         |
      |                         long long int
In file included from gap.cpp:4:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:44:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   44 |         MinMax(0, 1e18, mini, maxi);
      |                               ^~~~
      |                               |
      |                               long long int
In file included from gap.cpp:4:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:49:38: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   49 |             MinMax(le, le + gap - 1, temp1, temp2);
      |                                      ^~~~~
      |                                      |
      |                                      long long int
In file included from gap.cpp:4:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:49:45: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   49 |             MinMax(le, le + gap - 1, temp1, temp2);
      |                                             ^~~~~
      |                                             |
      |                                             long long int
In file included from gap.cpp:4:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:57:34: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   57 |             MinMax(le, maxi - 1, temp1, temp2);
      |                                  ^~~~~
      |                                  |
      |                                  long long int
In file included from gap.cpp:4:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:57:41: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   57 |             MinMax(le, maxi - 1, temp1, temp2);
      |                                         ^~~~~
      |                                         |
      |                                         long long int
In file included from gap.cpp:4:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:58:29: error: continue statement not within a loop
   58 |             if(temp1 == -1) continue;
      |                             ^~~~~~~~