제출 #260985

#제출 시각아이디문제언어결과실행 시간메모리
260985SamAnd로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define m_p make_pair #define fi first #define se second #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() typedef long long ll; const int N = 1000006; struct ban { int x, y; }; bool soy(const ban& a, const ban& b) { return a.y < b.y; } bool sox(const ban& a, const ban& b) { return a.x < b.x; } int n; ban a[N]; int xn, yn; int x[N], y[N]; bool stg(int q) { multiset<pair<int, int> > s; for (int i = 0; i < xn; ++i) { s.insert(m_p(x[i], q)); } vector<int> v; for (int i = n - 1; i >= 0; --i) { auto it = s.upper_bound(m_p(a[i].x, 0)); if (it == s.end()) { v.push_back(a[i].y); continue; } pair<int, int> u = *it; s.erase(it); u.se--; if (u.se) s.insert(u); } s.clear(); for (int i = 0; i < yn; ++i) { s.insert(m_p(y[i], q)); } sort(all(v)); reverse(all(v)); for (int i = 0; i < sz(v); ++i) { auto it = s.upper_bound(m_p(v[i], 0)); if (it == s.end()) return false; pair<int, int> u = *it; s.erase(it); u.se--; if (u.se) s.insert(u); } return true; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { xn = A; yn = B; for (int i = 0; i < xn; ++i) x[i] = X[i]; for (int i = 0; i < yn; ++i) y[i] = Y[i]; n = T; for (int i = 0; i < n; ++i) { a[i].x = W[i]; a[i].y = S[i]; } sort(x, x + xn); sort(y, y + yn); for (int i = 0; i < n; ++i) { if (xn && a[i].x < x[xn - 1]) continue; if (yn && a[i].y < y[yn - 1]) continue; return -1; } sort(a, a + n, soy); int l = 1, r = n; int ans; while (l <= r) { int m = (l + r) / 2; if (stg(m)) { ans = m; r = m - 1; } else l = m + 1; } return ans; }

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

robots.cpp:28:9: error: 'int yn' redeclared as different kind of symbol
 int xn, yn;
         ^~
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from robots.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:252:1: note: previous declaration 'double yn(int, double)'
 __MATHCALL (yn,, (int, _Mdouble_));
 ^
robots.cpp: In function 'bool stg(int)':
robots.cpp:56:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     for (int i = 0; i < yn; ++i)
                         ^~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:80:10: error: assignment of function 'double yn(int, double)'
     yn = B;
          ^
robots.cpp:80:10: error: cannot convert 'int' to 'double(int, double) noexcept' in assignment
robots.cpp:83:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     for (int i = 0; i < yn; ++i)
                         ^~
robots.cpp:94:15: error: invalid operands of types 'int [1000006]' and 'double(int, double) noexcept' to binary 'operator+'
     sort(y, y + yn);
             ~~^~~~
robots.cpp:100:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         if (yn && a[i].y < y[yn - 1])
                              ~~~^~~
robots.cpp:100:36: error: invalid types 'int [1000006][double (*)(int, double) noexcept]' for array subscript
         if (yn && a[i].y < y[yn - 1])
                                    ^