# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
962951 | serkanrashid | 로봇 (IOI13_robots) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
struct toy
{
int w,s;
toy(){};
toy(int wi, int si)
{
w = wi;
s = si;
}
};
int t;
toy k[1e6];
int a,b,x[5e4],y[5e4];
bool cmp2(toy p1, toy p2)
{
if(p1.s==p2.s) return p1.w>p2.w;
return p1.s<p2.s;
}
bool check(int z)
{
int p = 0;
for(int i = 0; i < a; i++)
{
int br = 0;
while(br<z&&p<t&&k[p].w<=x[i])
{
br++;
p++;
}
}
vector<toy>pom;
for(int i = p; i < t; i++) pom.push_back(k[i]);
sort(pom.begin(),pom.end(),cmp2);
p = 0;
for(int i = 0; i < b; i++)
{
int br = 0;
while(br<z&&p<pom.size()&&k[p].s<=y[i])
{
br++;
p++;
}
}
return p>=pom.size();
}
bool cmp1(toy p1, toy p2)
{
if(p1.w==p2.w) return p1.s>p2.s;
return p1.w<p2.w;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
a = A;
b = B;
for(int i = 0; i < A; i++) x[i] = X[i]-1;
for(int i = 0; i < B; i++) y[i] = Y[i]-1;
t = T;
for(int i = 0; i < T; i++)
{
k[i].w = W[i];
k[i].s = S[i];
}
if(a) sort(x,x+a);
if(b) sort(y,y+b);
for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1;
sort(a,a+t,cmp1);
int l = 1, r = t;
int mid;
while(l<=r)
{
mid = (l+r)/2;
if(check(mid)) r = mid-1;
else l = mid+1;
}
return l;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp:18:7: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 18 | toy k[1e6]; | ^~~ robots.cpp:18:7: error: could not convert '1.0e+6' from 'double' to 'long unsigned int' robots.cpp:18:7: error: size of array 'k' has non-integral type 'double' robots.cpp:20:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 20 | int a,b,x[5e4],y[5e4]; | ^~~ robots.cpp:20:11: error: could not convert '5.0e+4' from 'double' to 'long unsigned int' robots.cpp:20:11: error: size of array 'x' has non-integral type 'double' robots.cpp:20:18: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 20 | int a,b,x[5e4],y[5e4]; | ^~~ robots.cpp:20:18: error: could not convert '5.0e+4' from 'double' to 'long unsigned int' robots.cpp:20:18: error: size of array 'y' has non-integral type 'double' robots.cpp: In function 'bool check(int)': robots.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 47 | while(br<z&&p<pom.size()&&k[p].s<=y[i]) | ~^~~~~~~~~~~ robots.cpp:53:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 53 | return p>=pom.size(); | ~^~~~~~~~~~~~ robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)': robots.cpp:76:40: error: 'w' was not declared in this scope 76 | for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1; | ^ robots.cpp:76:59: error: 's' was not declared in this scope 76 | for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1; | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from robots.cpp:2: /usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]': /usr/include/c++/10/bits/stl_algo.h:1886:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1977:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(toy, toy)]' robots.cpp:77:20: required from here /usr/include/c++/10/bits/stl_algo.h:1849:3: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1849 | __val = _GLIBCXX_MOVE(*__i); | ^~~~~ /usr/include/c++/10/bits/stl_algo.h:1851:8: error: invalid type argument of unary '*' (have 'int') 1851 | *__first = _GLIBCXX_MOVE(__val); | ^~~~~~~~ /usr/include/c++/10/bits/stl_algo.h:1849:3: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1849 | __val = _GLIBCXX_MOVE(*__i); | ^~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, 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 = int; _Iterator2 = int; _Compare = bool (*)(toy, toy)]': /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 = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1924:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1958:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(toy, toy)]' robots.cpp:77:20: required from here /usr/include/c++/10/bits/predefined_ops.h:156:31: error: invalid type argument of unary '*' (have 'int') 156 | { return bool(_M_comp(*__it1, *__it2)); } | ^~~~~~ /usr/include/c++/10/bits/predefined_ops.h:156:39: error: invalid type argument of unary '*' (have 'int') 156 | { return bool(_M_comp(*__it1, *__it2)); } | ^~~~~~ In file included from /usr/include/c++/10/bits/stl_algo.h:61, from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from robots.cpp:2: /usr/include/c++/10/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]': /usr/include/c++/10/bits/stl_algo.h:1666:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1937:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1953:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(toy, toy)]' robots.cpp:77:20: required from here /usr/include/c++/10/bits/stl_heap.h:343:4: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 343 | _ValueType; | ^~~~~~~~~~ /usr/include/c++/10/bits/stl_heap.h:345:4: error: no type named 'difference_type' in 'struct std::iterator_traits<int>' 345 | _DistanceType; | ^~~~~~~~~~~~~ /usr/include/c++/10/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]': /usr/include/c++/10/bits/stl_algo.h:1669:19: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1937:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1953:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(toy, toy)>]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(toy, toy)]' robots.cpp:77:20: required from here /usr/include/c++/10/bits/stl_heap.h:257:2: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 257 | _ValueType; | ^~~~~~~~~~ /usr/include/c++/10/bits/stl_heap.h:259:2: error: no type named 'difference_type' in 'struct std::iterator_traits<int>' 259 | _DistanceType; | ^~~~~~~~~~~~~ /usr/include/c++/10/bits/stl_heap.h:262:7: error: invalid type argument of unary '*' (have 'int') 262 | *__result = _GLIBCXX_MOVE(*__first); | ^~~~~~~~~ In file included from /usr/include/c++/10/bits/nested_exception.h:40, from /usr/include/c++/10/exception:148, from /usr/include/c++/10/ios:39, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from robots.cpp:2: /usr/include/c++/10/bits/stl_heap.h:262:19: error: invalid type argument of unary '*' (have 'int') 262 | *__result = _GLIBCXX_MOVE(*__first); | ^~~~~~~~~~~~~