# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
404701 | ly20 | 로봇 (IOI13_robots) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
//x -> w
//y -> s
int x[MAXN], y[MAXN], w[MAXN], s[MAXN];
pair <int, int> va[MAXN], vb[MAXN];
int n, a, b;
int marc[MAXN];
bool cmp1(int a, int b) {
return w[a] < w[b];
}
bool cmp2(int a, int b) {
return s[a] < s[b];
}
bool teste(int t) {
priority_queue < pair <int, int> > s;
int ts = 0;
int cur = 0;
for(int i = 0; i < a; i++) {
while(w[va[cur]] < x[i]) {
s.push_back(make_pair(s[va[cur]], va[cur]));
}
int cs = 0;
while(cs < t) {
if(s.empty()) break;
pair <int, int> temp = s.front();
s.pop_back();
cs++;
marc[temp.second] = 1;
}
}
priority_queue <pair <int, int> > s2;
for(int i = 0; i < n; i++) {
if(marc[i] == 0) s2.insert(make_pair(-s[i], i));
}
for(int i = b - 1; i >= 0; i--) {
int cs = 0;
while(cs < t) {
if(s2.empty()) break;
pair <int, int> temp = s.front();
if(-temp.first >= y[i]) break;
s.pop_back();
cs++;
}
}
return ts == n;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
n = T;
a = A; b = B;
for(int i = 0; i < T; i++) {
va[i] = i;
vb[i] = i;
w[i] = W[i]; s[i] = S[i];
}
sort(va, va + n, cmp1);
sort(vb, vb + n, cmp2);
for(int i = 0; i < a; i++) x[i] = X[i];
for(int i = 0; i < b; i++) y[i] = Y[i];
sort(x, x + a); sort(y, y + b);
int ini = 1, fim = MAXN;
while(ini < fim) {
for(int i = 0; i < t; i++) marc[i] = 0;
int m = (ini + fim) / 2;
if(teste(m)) {
fim = m;
}
else ini = m + 1;
}
if(ini == MAXN) ini = -1;
return ini;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool teste(int)': robots.cpp:24:16: error: no match for 'operator[]' (operand types are 'int [1123456]' and 'std::pair<int, int>') 24 | while(w[va[cur]] < x[i]) { | ^ robots.cpp:25:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'push_back' 25 | s.push_back(make_pair(s[va[cur]], va[cur])); | ^~~~~~~~~ robots.cpp:25:36: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'std::pair<int, int>') 25 | s.push_back(make_pair(s[va[cur]], va[cur])); | ^ robots.cpp:30:38: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'front' 30 | pair <int, int> temp = s.front(); | ^~~~~ robots.cpp:31:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'pop_back' 31 | s.pop_back(); | ^~~~~~~~ robots.cpp:38:29: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'insert' 38 | if(marc[i] == 0) s2.insert(make_pair(-s[i], i)); | ^~~~~~ robots.cpp:38:48: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'int') 38 | if(marc[i] == 0) s2.insert(make_pair(-s[i], i)); | ^ robots.cpp:44:38: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'front' 44 | pair <int, int> temp = s.front(); | ^~~~~ robots.cpp:46:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'pop_back' 46 | s.pop_back(); | ^~~~~~~~ robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)': robots.cpp:56:17: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int') 56 | va[i] = i; | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from robots.cpp:2: /usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<int, int>&]' 390 | operator=(typename conditional< | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:393:41: note: no known conversion for argument 1 from 'int' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch&>::type' {aka 'const std::pair<int, int>&'} 390 | operator=(typename conditional< | ~~~~~~~~~~~~~~~~~~~~~ 391 | __and_<is_copy_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 392 | is_copy_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | const pair&, const __nonesuch&>::type __p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<int, int>&&]' 401 | operator=(typename conditional< | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:404:31: note: no known conversion for argument 1 from 'int' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch&&>::type' {aka 'std::pair<int, int>&&'} 401 | operator=(typename conditional< | ~~~~~~~~~~~~~~~~~~~~~ 402 | __and_<is_move_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 403 | is_move_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 404 | pair&&, __nonesuch&&>::type __p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]' 418 | operator=(const pair<_U1, _U2>& __p) | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:418:2: note: template argument deduction/substitution failed: robots.cpp:56:17: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 56 | va[i] = i; | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from robots.cpp:2: /usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]' 430 | operator=(pair<_U1, _U2>&& __p) | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:430:2: note: template argument deduction/substitution failed: robots.cpp:56:17: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 56 | va[i] = i; | ^ robots.cpp:57:17: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int') 57 | vb[i] = i; | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from robots.cpp:2: /usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<int, int>&]' 390 | operator=(typename conditional< | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:393:41: note: no known conversion for argument 1 from 'int' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch&>::type' {aka 'const std::pair<int, int>&'} 390 | operator=(typename conditional< | ~~~~~~~~~~~~~~~~~~~~~ 391 | __and_<is_copy_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 392 | is_copy_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | const pair&, const __nonesuch&>::type __p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<int, int>&&]' 401 | operator=(typename conditional< | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:404:31: note: no known conversion for argument 1 from 'int' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch&&>::type' {aka 'std::pair<int, int>&&'} 401 | operator=(typename conditional< | ~~~~~~~~~~~~~~~~~~~~~ 402 | __and_<is_move_assignable<_T1>, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 403 | is_move_assignable<_T2>>::value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 404 | pair&&, __nonesuch&&>::type __p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]' 418 | operator=(const pair<_U1, _U2>& __p) | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:418:2: note: template argument deduction/substitution failed: robots.cpp:57:17: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 57 | vb[i] = i; | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from robots.cpp:2: /usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]' 430 | operator=(pair<_U1, _U2>&& __p) | ^~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:430:2: note: template argument deduction/substitution failed: robots.cpp:57:17: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 57 | vb[i] = i; | ^ robots.cpp:67:28: error: 't' was not declared in this scope 67 | for(int i = 0; i < t; i++) marc[i] = 0; | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from robots.cpp:2: /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = std::pair<int, int>*; _Iterator2 = std::pair<int, int>*; _Compare = bool (*)(int, int)]': /usr/include/c++/10/bits/stl_algo.h:82:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1924:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1958:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::pair<int, int>*; _Compare = bool (*)(int, int)]' robots.cpp:60:26: required from here /usr/include/c++/10/bits/predefined_ops.h:156:30: error: cannot convert 'std::pair<int, int>' to 'int' in argument passing 156 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<int, int>; _Iterator = std::pair<int, int>*; _Compare = bool (*)(int, int)]': /usr/include/c++/10/bits/stl_algo.h:1826:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1854:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1886:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1977:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::pair<int, int>*; _Compare = bool (*)(int, int)]' robots.cpp:60:26: required from here /usr/include/c++/10/bits/predefined_ops.h:238:23: error: cannot convert 'std::pair<int, int>' to 'int' in argument passing 238 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = std::pair<int, int>*; _Value = std::pair<int, int>; _Compare = bool (*)(int, int)]': /usr/include/c++/10/bits/stl_heap.h:139:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = std::pair<int, int>*; _Distance = long int; _Tp = std::pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_heap.h:246:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Distance = long int; _Tp = std::pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_heap.h:355:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1666:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1937:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1953:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::pair<int, int>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::pair<int, int>*; _Compare = bool (*)(int, int)]' robots.cpp:60:26: required from here /usr/include/c++/10/bits/predefined_ops.h:194:23: error: cannot convert 'std::pair<int, int>' to 'int' in argument passing 194 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~