제출 #1105408

#제출 시각아이디문제언어결과실행 시간메모리
1105408xydwe12312Cloud Computing (CEOI18_clo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // Macros #define pb push_back #define pf push_front #define ff first #define ss second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define up(v) upper_bound(v) #define low(v) lower_bound(v) // Read and Print #define read(a, n) for(ll i = 0; i < n; ++i) cin >> a[i]; #define print(a, n) for(ll i = 0; i < n; ++i){ cout << a[i] << " ";} cout << "\n"; #define endl "\n" #define sp " " // Typedefs typedef long double ld; typedef long long int ll; typedef pair<ll, ll> pll; typedef pair<lli, lli> plli; typedef pair<ll, ll> pii; // Changed to ll typedef vector<lli> vi; typedef vector<vector<lli>> vvi; using vec = vector<ll>; // Changed to ll // Constants const ll mxn = 1e6 + 5; const ll mod = 1e9 + 7; // Solve const ll N = 1e5 + 5; void solve() { ll n; cin >> n; vi c(n), f(n), v(n); vector<tuple<ll, ll, ll>> a; // Changed to ll ll sum = 0; for (ll i = 0; i < n; i++) { cin >> c[i] >> f[i] >> v[i]; a.pb({f[i], -v[i], c[i]}); sum += c[i]; } ll m; cin >> m; vector<ll> C(m), F(m), V(m); // Changed to ll for (ll i = 0; i < m; i++) { // Changed to ll cin >> C[i] >> F[i] >> V[i]; a.pb({F[i], V[i], C[i]}); } sort(rall(a)); vi dp(sum + 1, LLONG_MIN); dp[0] = 0; for (auto &[i, k, j] : a) { if (k > 0) { vector<ll> R = dp; for (ll l = j; l <= sum; l++) { // Changed to ll if (R[l] != LLONG_MIN) dp[l - j] = max(dp[l - j], R[l] + k); } } else { for (ll l = sum - j; l >= 0; l--) { // Changed to ll if (dp[l] != LLONG_MIN) dp[l + j] = max(dp[l + j], dp[l] + k); } } } sort(rall(dp)); cout << dp[0] << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }

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

clo.cpp:24:14: error: 'lli' was not declared in this scope; did you mean 'll'?
   24 | typedef pair<lli, lli> plli;
      |              ^~~
      |              ll
clo.cpp:24:19: error: 'lli' was not declared in this scope; did you mean 'll'?
   24 | typedef pair<lli, lli> plli;
      |                   ^~~
      |                   ll
clo.cpp:24:22: error: template argument 1 is invalid
   24 | typedef pair<lli, lli> plli;
      |                      ^
clo.cpp:24:22: error: template argument 2 is invalid
clo.cpp:26:16: error: 'lli' was not declared in this scope; did you mean 'plli'?
   26 | typedef vector<lli> vi;
      |                ^~~
      |                plli
clo.cpp:26:19: error: template argument 1 is invalid
   26 | typedef vector<lli> vi;
      |                   ^
clo.cpp:26:19: error: template argument 2 is invalid
clo.cpp:27:23: error: 'lli' was not declared in this scope; did you mean 'plli'?
   27 | typedef vector<vector<lli>> vvi;
      |                       ^~~
      |                       plli
clo.cpp:27:23: error: template argument 1 is invalid
clo.cpp:27:23: error: template argument 2 is invalid
clo.cpp:27:26: error: template argument 1 is invalid
   27 | typedef vector<vector<lli>> vvi;
      |                          ^~
clo.cpp:27:26: error: template argument 2 is invalid
clo.cpp: In function 'void solve()':
clo.cpp:45:11: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   45 |   cin >> c[i] >> f[i] >> v[i];
      |           ^
clo.cpp:45:19: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   45 |   cin >> c[i] >> f[i] >> v[i];
      |                   ^
clo.cpp:45:27: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   45 |   cin >> c[i] >> f[i] >> v[i];
      |                           ^
clo.cpp:46:10: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   46 |   a.pb({f[i], -v[i], c[i]});
      |          ^
clo.cpp:46:17: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   46 |   a.pb({f[i], -v[i], c[i]});
      |                 ^
clo.cpp:46:23: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   46 |   a.pb({f[i], -v[i], c[i]});
      |                       ^
clo.cpp:46:27: error: no matching function for call to 'std::vector<std::tuple<long long int, long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   46 |   a.pb({f[i], -v[i], c[i]});
      |                           ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<long long int, long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::tuple<long long int, long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::tuple<long long int, long long int, long long int> >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
clo.cpp:47:11: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   47 |   sum += c[i];
      |           ^
clo.cpp:59:26: error: expression list treated as compound expression in initializer [-fpermissive]
   59 |  vi dp(sum + 1, LLONG_MIN);
      |                          ^
clo.cpp:59:12: warning: left operand of comma operator has no effect [-Wunused-value]
   59 |  vi dp(sum + 1, LLONG_MIN);
      |        ~~~~^~~
clo.cpp:59:26: warning: overflow in conversion from 'long long int' to 'vi' {aka 'int'} changes value from '-9223372036854775808' to '0' [-Woverflow]
   59 |  vi dp(sum + 1, LLONG_MIN);
      |                          ^
clo.cpp:60:4: error: invalid types 'vi {aka int}[int]' for array subscript
   60 |  dp[0] = 0;
      |    ^
clo.cpp:62:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   62 |  for (auto &[i, k, j] : a) {
      |             ^
clo.cpp:64:19: error: conversion from 'vi' {aka 'int'} to non-scalar type 'std::vector<long long int>' requested
   64 |    vector<ll> R = dp;
      |                   ^~
clo.cpp:67:8: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   67 |      dp[l - j] = max(dp[l - j], R[l] + k);
      |        ^
clo.cpp:67:24: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   67 |      dp[l - j] = max(dp[l - j], R[l] + k);
      |                        ^
clo.cpp:71:11: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   71 |     if (dp[l] != LLONG_MIN)
      |           ^
clo.cpp:72:8: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   72 |      dp[l + j] = max(dp[l + j], dp[l] + k);
      |        ^
clo.cpp:72:24: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   72 |      dp[l + j] = max(dp[l + j], dp[l] + k);
      |                        ^
clo.cpp:72:35: error: invalid types 'vi {aka int}[ll {aka long long int}]' for array subscript
   72 |      dp[l + j] = max(dp[l + j], dp[l] + k);
      |                                   ^
clo.cpp:10:23: error: request for member 'rbegin' in 'dp', which is of non-class type 'vi' {aka 'int'}
   10 | #define rall(v)     v.rbegin(), v.rend()
      |                       ^~~~~~
clo.cpp:76:7: note: in expansion of macro 'rall'
   76 |  sort(rall(dp));
      |       ^~~~
clo.cpp:10:35: error: request for member 'rend' in 'dp', which is of non-class type 'vi' {aka 'int'}
   10 | #define rall(v)     v.rbegin(), v.rend()
      |                                   ^~~~
clo.cpp:76:7: note: in expansion of macro 'rall'
   76 |  sort(rall(dp));
      |       ^~~~
clo.cpp:77:12: error: invalid types 'vi {aka int}[int]' for array subscript
   77 |  cout << dp[0] << endl;
      |            ^