제출 #263755

#제출 시각아이디문제언어결과실행 시간메모리
263755T0p_Gap (APIO16_gap)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; vector<long long> v; long long findGap(int m, int n) { if(m == 1) { int left = n-2; long long s = 0, t = 1e18, mn, mx; MinMax(s, t, &mn, &mx); v.push_back(mn); v.push_back(mx); s = mn+1; t = mx-1; while(true) { MinMax(s, t, &mn, &mx); v.push_back(mn); left--; if(!left) break ; v.push_back(mx); left--; if(!left) break ; s = mn+1, t = mx-1; } assert(v.size() == n); sort(v.begin(), v.end()); for(int i=1 ; i<v.size() ; i++) ans = max(ans, v[i] - v[i-1]); return ans; } else { } }

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

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from gap.cpp:1:
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |   assert(v.size() == n);
      |          ~~~~~~~~~^~~~
gap.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i=1 ; i<v.size() ; i++)
      |                 ~^~~~~~~~~
gap.cpp:32:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |    ans = max(ans, v[i] - v[i-1]);
      |    ^~~
      |    abs
gap.cpp:33:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |   return ans;
      |          ^~~
      |          abs