Submission #61669

#TimeUsernameProblemLanguageResultExecution timeMemory
61669KHUSRAVWiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#include "wiring.h" using namespace std ; long long min_total_length(vector<int> r , vector<int> b){ long long used[100001] , ans = 0 , u1[100001] , u2[100001]; vector<pair<int , pair<int , int > > > v ; for(int i = 0 ; i <= 100000 ; i++) u1[i] = u2[i] = 0; if(r.size() > b.size()) swap(r , b); for(int i = 0 ; i < r.size() ; i ++){ for(int j = 0 ; j < b.size() ; j ++){ v.push_back({abs(r[i] - b[j]) , {i , j}}); u1[i] ++ ; u2[j] ++ ; ans = ans + abs(r[i] - b[j]); } } sort(v.begin() , v.end()); reverse(v.begin() , v.end()); for(int i = 0 ; i < v.size() ; i++){ cout << v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<'\n'; } for(int i = 0 ; i < v.size() ; i++){ if(u1[v[i].second.first] > 1 && u2[v[i].second.second] > 1){ ans = ans - v[i].first; u1[v[i].second.first] --; u2[v[i].second.second] --; } else{ //cout << r[v[i].second.first] <<" - "<<b[v[i].second.second] <<'\n'; } } return 1 ; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:12:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < r.size() ; i ++){
                     ~~^~~~~~~~~~
wiring.cpp:13:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0 ; j < b.size() ; j ++){
                         ~~^~~~~~~~~~
wiring.cpp:14:26: error: 'abs' was not declared in this scope
             v.push_back({abs(r[i] - b[j]) , {i , j}});
                          ^~~
wiring.cpp:14:26: note: suggested alternative: 'ans'
             v.push_back({abs(r[i] - b[j]) , {i , j}});
                          ^~~
                          ans
wiring.cpp:14:53: error: no matching function for call to 'std::vector<std::pair<int, std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
             v.push_back({abs(r[i] - b[j]) , {i , j}});
                                                     ^
In file included from /usr/include/c++/7/vector:64:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, std::pair<int, int> >]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, std::pair<int, int> >&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, std::pair<int, int> >]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, std::pair<int, int> > >::value_type&& {aka std::pair<int, std::pair<int, int> >&&}'
wiring.cpp:21:5: error: 'sort' was not declared in this scope
     sort(v.begin() , v.end());
     ^~~~
wiring.cpp:21:5: note: suggested alternative: 'short'
     sort(v.begin() , v.end());
     ^~~~
     short
wiring.cpp:22:5: error: 'reverse' was not declared in this scope
     reverse(v.begin() , v.end());
     ^~~~~~~
wiring.cpp:23:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < v.size() ; i++){
                     ~~^~~~~~~~~~
wiring.cpp:24:9: error: 'cout' was not declared in this scope
         cout << v[i].first<<" "<<v[i].second.first<<" "<<v[i].second.second<<'\n';
         ^~~~
wiring.cpp:26:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < v.size() ; i++){
                     ~~^~~~~~~~~~
wiring.cpp:5:15: warning: unused variable 'used' [-Wunused-variable]
     long long used[100001] , ans = 0 , u1[100001] , u2[100001];
               ^~~~