Submission #888331

#TimeUsernameProblemLanguageResultExecution timeMemory
888331hwyFortune Telling 2 (JOI14_fortune_telling2)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n, k; vector<ll> cards; vector<ll> ops; ll ans = 0; ll curr_num; for (ll i = 0; i < n; i++) { ll a, b; cin >> a >> b; cards.push_back({a, b}); } for (ll i = 0; i < k; i++) { ll temp; cin >> temp; ops.push_back(temp); } for (ll i = 0; i < n; i++) { curr_num = cards[i].first; for (ll j = 0; j < k; j++) { if (curr_num <= ops[j]) { if (curr_num == cards[i].first) curr_num = cards[i].second; else if (curr_num == cards[i].second) curr_num = cards[i].first; } } ans += curr_num; } cout << ans; return 0; }

Compilation message (stderr)

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:18:25: error: no matching function for call to 'std::vector<long long int>::push_back(<brace-enclosed initializer list>)'
   18 |   cards.push_back({a, b});
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fortune_telling2.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 = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = 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 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 = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = 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<long long int>::value_type&&' {aka 'long long int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
fortune_telling2.cpp:28:23: error: request for member 'first' in 'cards.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   28 |   curr_num = cards[i].first;
      |                       ^~~~~
fortune_telling2.cpp:31:30: error: request for member 'first' in 'cards.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   31 |     if (curr_num == cards[i].first)
      |                              ^~~~~
fortune_telling2.cpp:32:26: error: request for member 'second' in 'cards.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   32 |      curr_num = cards[i].second;
      |                          ^~~~~~
fortune_telling2.cpp:33:35: error: request for member 'second' in 'cards.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   33 |     else if (curr_num == cards[i].second)
      |                                   ^~~~~~
fortune_telling2.cpp:34:26: error: request for member 'first' in 'cards.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   34 |      curr_num = cards[i].first;
      |                          ^~~~~