제출 #1314309

#제출 시각아이디문제언어결과실행 시간메모리
1314309kingboyBalloons (CEOI11_bal)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <stack> using namespace std; int main() { int n; cin >> n; stack<pair<double, double>> st; for (int x=0;x<n;x++) { int xpos, maxRadius; cin >> xpos >> maxRadius; while (!st.empty()) { double maxAllowableRadius = (x-st.top().first) * (x-st.top().first) / (4*st.top().second); if (maxAllowableRadius <= maxRadius) { maxRadius = maxAllowableRadius; } // covers previous balloon if (maxRadius >= st.top().second) { st.pop(); } else { break; } } cout << r << endl; st.push({xpos, r}); } }

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

bal.cpp: In function 'int main()':
bal.cpp:27:17: error: 'r' was not declared in this scope
   27 |         cout << r << endl;
      |                 ^
bal.cpp:28:16: error: no matching function for call to 'std::stack<std::pair<double, double> >::push(<brace-enclosed initializer list>)'
   28 |         st.push({xpos, r});
      |         ~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/stack:63,
                 from bal.cpp:2:
/usr/include/c++/13/bits/stl_stack.h:260:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<double, double>; _Sequence = std::deque<std::pair<double, double>, std::allocator<std::pair<double, double> > >; value_type = std::pair<double, double>]'
  260 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_stack.h:260:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::stack<std::pair<double, double> >::value_type&' {aka 'const std::pair<double, double>&'}
  260 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_stack.h:265:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<double, double>; _Sequence = std::deque<std::pair<double, double>, std::allocator<std::pair<double, double> > >; value_type = std::pair<double, double>]'
  265 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_stack.h:265:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::stack<std::pair<double, double> >::value_type&&' {aka 'std::pair<double, double>&&'}
  265 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~