Submission #1255077

#TimeUsernameProblemLanguageResultExecution timeMemory
1255077otariusFestival (IOI25_festival)C++20
Compilation error
0 ms0 KiB
#include "festival.h" #include <bits/stdc++.h> #include <bits/extc++.h> using namespace __gnu_pbds; using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define ull unsigned long long #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count()); // #define int long long // #define int unsigned long long // #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> // #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update> // const ll mod = 1e9 + 7; // const ll mod = 998244353; const ll inf = 1e9; const ll biginf = 1e18; // const int maxN; bool comp(array<int, 3> a, array<int, 3> b) { return a[0] * a[1] * b[1] + b[0] * b[1] < a[0] * a[1] * b[1] + a[0] * a[1]; } vector<int> max_coupons(int a, vector<int> p, vector<int> t) { vector<array<int, 3>> v; for (int i = 0; i < p.size(); i++) v.pb({p[i], t[i], i}); sort(all(v), comp); vector<int> ans; for (auto i : v) ans.pb(v[i][2]); return ans; } // int main() { // int N, A; // assert(2 == scanf("%d %d", &N, &A)); // std::vector<int> P(N), T(N); // for (int i = 0; i < N; i++) // assert(2 == scanf("%d %d", &P[i], &T[i])); // fclose(stdin); // std::vector<int> R = max_coupons(A, P, T); // int S = R.size(); // printf("%d\n", S); // for (int i = 0; i < S; i++) // printf("%s%d", (i == 0 ? "" : " "), R[i]); // printf("\n"); // fclose(stdout); // return 0; // }

Compilation message (stderr)

festival.cpp: In function 'std::vector<int> max_coupons(int, std::vector<int>, std::vector<int>)':
festival.cpp:46:30: error: no match for 'operator[]' (operand types are 'std::vector<std::array<int, 3> >' and 'std::array<int, 3>')
   46 |     for (auto i : v) ans.pb(v[i][2]);
      |                              ^
In file included from /usr/include/c++/11/vector:67,
                 from festival.h:1,
                 from festival.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::reference = std::array<int, 3>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::array<int, 3>' to 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::const_reference = const std::array<int, 3>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::array<int, 3>' to 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~