# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
660589 | Trisanu_Das | 전선 연결 (IOI17_wiring) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <bits/stdc++.h>
#define fi first
#define si second
using namespace std;
long long min_total_length(vector<int> r, vector<int> b) {
int n, m; n = r.size(); m=b.size();
vector<pair<int, int>> a;
for (auto &i:r) a.emplace_back(i, 1);
for (auto &i:b) a.emplace_back(i, -1);
sort(a.begin(), a.end());
reverse(r.begin(), r.end());
reverse(b.begin(), b.end());
int x = m;
ll r = INT_MIN, b = INT_MIN, ans = 0, s = 0;
vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX});
lst[m] = {0, 0};
for (auto &i:a) {
ll temp = 0;
(i.se == 1?r : b).pop_back();
x += i.se;
s += i.fi * i.se;
if (i.se == 1) {
r = i.fi;
temp = ans + i.fi - b;
if (b.size()) temp = min(temp, ans + b.back() - i.fi);
}
if (i.se == -1) {
b =i .fi;
temp = ans+i.fi-r;
if (r.size()) temp = min(temp, ans + r.back()-i.fi);
}
ans=min(temp, lst[x].fi + abs(lst[x].se - s));
lst[x] = {ans, s};
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)': wiring.cpp:16:2: error: 'll' was not declared in this scope 16 | ll r = INT_MIN, b = INT_MIN, ans = 0, s = 0; | ^~ wiring.cpp:17:20: error: template argument 1 is invalid 17 | vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX}); | ^~ wiring.cpp:17:20: error: template argument 2 is invalid wiring.cpp:17:56: error: expression list treated as compound expression in initializer [-fpermissive] 17 | vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX}); | ^ wiring.cpp:17:33: warning: left operand of comma operator has no effect [-Wunused-value] 17 | vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX}); | ~~~~~~^~~ wiring.cpp:17:56: error: cannot convert '<brace-enclosed initializer list>' to 'int' in initialization 17 | vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX}); | ^ wiring.cpp:18:5: error: invalid types 'int[int]' for array subscript 18 | lst[m] = {0, 0}; | ^ wiring.cpp:21:5: error: expected ';' before 'temp' 21 | ll temp = 0; | ^~~~~ | ; wiring.cpp:22:6: error: 'struct std::pair<int, int>' has no member named 'se' 22 | (i.se == 1?r : b).pop_back(); | ^~ wiring.cpp:23:10: error: 'struct std::pair<int, int>' has no member named 'se' 23 | x += i.se; | ^~ wiring.cpp:24:3: error: 's' was not declared in this scope 24 | s += i.fi * i.se; | ^ wiring.cpp:24:17: error: 'struct std::pair<int, int>' has no member named 'se' 24 | s += i.fi * i.se; | ^~ wiring.cpp:25:9: error: 'struct std::pair<int, int>' has no member named 'se' 25 | if (i.se == 1) { | ^~ wiring.cpp:3:12: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 3 | #define fi first | ^~~~~ wiring.cpp:26:10: note: in expansion of macro 'fi' 26 | r = i.fi; | ^~ In file included from /usr/include/c++/10/vector:72, from wiring.h:1, from wiring.cpp:1: /usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/10/vector:67, from wiring.h:1, from wiring.cpp:1: /usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ wiring.cpp:27:4: error: 'temp' was not declared in this scope 27 | temp = ans + i.fi - b; | ^~~~ wiring.cpp:27:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 27 | temp = ans + i.fi - b; | ^~~ | abs wiring.cpp:30:9: error: 'struct std::pair<int, int>' has no member named 'se' 30 | if (i.se == -1) { | ^~ wiring.cpp:3:12: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 3 | #define fi first | ^~~~~ wiring.cpp:31:10: note: in expansion of macro 'fi' 31 | b =i .fi; | ^~ In file included from /usr/include/c++/10/vector:72, from wiring.h:1, from wiring.cpp:1: /usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/10/vector:67, from wiring.h:1, from wiring.cpp:1: /usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ wiring.cpp:32:4: error: 'temp' was not declared in this scope 32 | temp = ans+i.fi-r; | ^~~~ wiring.cpp:32:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | temp = ans+i.fi-r; | ^~~ | abs wiring.cpp:35:3: error: 'ans' was not declared in this scope; did you mean 'abs'? 35 | ans=min(temp, lst[x].fi + abs(lst[x].se - s)); | ^~~ | abs wiring.cpp:35:11: error: 'temp' was not declared in this scope 35 | ans=min(temp, lst[x].fi + abs(lst[x].se - s)); | ^~~~ wiring.cpp:35:20: error: invalid types 'int[int]' for array subscript 35 | ans=min(temp, lst[x].fi + abs(lst[x].se - s)); | ^ wiring.cpp:35:36: error: invalid types 'int[int]' for array subscript 35 | ans=min(temp, lst[x].fi + abs(lst[x].se - s)); | ^ wiring.cpp:36:6: error: invalid types 'int[int]' for array subscript 36 | lst[x] = {ans, s}; | ^ wiring.cpp:38:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 38 | return ans; | ^~~ | abs