QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664809#7157. Bikes vs Carsspycoderyt#Compile Error//C++14775b2024-10-21 22:29:192024-10-21 22:29:19

Judging History

你现在查看的是最新测评结果

  • [2024-10-21 22:29:19]
  • 评测
  • [2024-10-21 22:29:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 505;
struct node{
    int a,b,w;
};
set<node> v;
int n,m,x,c,b;
int main() {
    // try the largest next edge, but before that check if theres already a larger connection
    cin>>n>>m;

    for(int i = 1;i<n;i++) {
        for(int j = 0;j<i;j++) {
            cin>>x;
            c = x;
            v.insert({i,j,m-x});
        }
    }
    for(int i = 1;i<n;i++) {
        for(int j = 0;j<i;j++) {
            cin>>x;
            b = x;
            v.insert({i,j,x});
        }
    }
    if(m-c > b || m - b > c) {
        cout << "NO\n";
        return 0;
    } 
    cout << v.size() << "\n";
    for(auto [a,b,c] : v)cout<<a<<" " << b << " " << c << "\n";

}

/*
2 1
0
1
*/

Details

answer.code: In function ‘int main()’:
answer.code:32:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   32 |     for(auto [a,b,c] : v)cout<<a<<" " << b << " " << c << "\n";
      |              ^
In file included from /usr/include/c++/13/string:49,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_function.h: In instantiation of ‘constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = node]’:
/usr/include/c++/13/bits/stl_tree.h:2118:35:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = node; _Val = node; _KeyOfValue = std::_Identity<node>; _Compare = std::less<node>; _Alloc = std::allocator<node>; key_type = node]’
/usr/include/c++/13/bits/stl_tree.h:2171:4:   required from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = node; _Key = node; _Val = node; _KeyOfValue = std::_Identity<node>; _Compare = std::less<node>; _Alloc = std::allocator<node>]’
/usr/include/c++/13/bits/stl_set.h:523:25:   required from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = node; _Compare = std::less<node>; _Alloc = std::allocator<node>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<node, node, std::_Identity<node>, std::less<node>, std::allocator<node> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<node>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<node>, node>::rebind<node>; typename _Alloc::value_type = node; value_type = node]’
answer.code:17:21:   required from here
/usr/include/c++/13/bits/stl_function.h:408:20: error: no match for ‘operator<’ (operand types are ‘const node’ and ‘const node’)
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/stl_pair.h:835:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’
  835 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::pair<_T1, _T2>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:67:
/usr/include/c++/13/bits/stl_iterator.h:455:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  455 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  500 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1705 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::move_iterator<_IteratorL>’
  408 |       { return __x < __y; }
      |               ...