제출 #660590

#제출 시각아이디문제언어결과실행 시간메모리
660590Trisanu_Das전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#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; long long 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:12: error: declaration of 'long long int r' shadows a parameter
   16 |  long long r = INT_MIN, b = INT_MIN, ans = 0, s = 0;
      |            ^
wiring.cpp:7:40: note: 'std::vector<int> r' previously declared here
    7 | long long min_total_length(vector<int> r, vector<int> b) {
      |                            ~~~~~~~~~~~~^
wiring.cpp:16:25: error: declaration of 'long long int b' shadows a parameter
   16 |  long long r = INT_MIN, b = INT_MIN, ans = 0, s = 0;
      |                         ^
wiring.cpp:7:55: note: 'std::vector<int> b' previously declared here
    7 | long long min_total_length(vector<int> r, vector<int> b) {
      |                                           ~~~~~~~~~~~~^
wiring.cpp:17:14: error: 'll' was not declared in this scope
   17 |  vector<pair<ll, ll>> lst(n + m + 1, {INT_MAX, INT_MAX});
      |              ^~
wiring.cpp:17:18: 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 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: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:27:4: error: 'temp' was not declared in this scope
   27 |    temp = ans + i.fi - b;
      |    ^~~~
wiring.cpp:28:10: error: request for member 'size' in 'b', which is of non-class type 'long long int'
   28 |    if (b.size()) temp = min(temp, ans + b.back() - i.fi);
      |          ^~~~
wiring.cpp:28:43: error: request for member 'back' in 'b', which is of non-class type 'long long int'
   28 |    if (b.size()) temp = min(temp, ans + b.back() - i.fi);
      |                                           ^~~~
wiring.cpp:30:9: error: 'struct std::pair<int, int>' has no member named 'se'
   30 |   if (i.se == -1) {
      |         ^~
wiring.cpp:32:4: error: 'temp' was not declared in this scope
   32 |    temp = ans+i.fi-r;
      |    ^~~~
wiring.cpp:33:10: error: request for member 'size' in 'r', which is of non-class type 'long long int'
   33 |    if (r.size()) temp = min(temp, ans + r.back()-i.fi);
      |          ^~~~
wiring.cpp:33:43: error: request for member 'back' in 'r', which is of non-class type 'long long int'
   33 |    if (r.size()) temp = min(temp, ans + r.back()-i.fi);
      |                                           ^~~~
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};
      |      ^