Submission #738355

#TimeUsernameProblemLanguageResultExecution timeMemory
738355Elvin_FritlWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "wiring.h" long long min_total_length(vector<int> r, vector<int> b){ set<pair<int,int>>s; vector<int>chek((int)b.size()*2 +1,0); for(int i=0;i<(int)r.size();i++){ b[r[i]]=1; } int j=0,n=(int)b.size()*2; for(int i=0;i<=n;i++){ if(b[j] > i){ s.insert({i,chek[i]}); } else if(b[j] <= i){ while(b[j] <= i && j<n){ j++; } } } long long res=0; for(int i=0;i<(int)b.size();i++){ int toto=chek[b[i]]; set<int>s1; while(s.size()!=0 && s.begin().last == toto){ s1.insert(s.begin().first); s.erase(s.begin()); } res+=abs(b[i] - s.begin().first); s.erase(s.begin()); while(s1.size()!=0){ s.insert({*s1.begin(),toto}); } } return res; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:28:40: error: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} has no member named 'last'
   28 |         while(s.size()!=0 && s.begin().last == toto){
      |                                        ^~~~
wiring.cpp:29:33: error: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} has no member named 'first'
   29 |             s1.insert(s.begin().first);
      |                                 ^~~~~
wiring.cpp:32:35: error: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} has no member named 'first'
   32 |         res+=abs(b[i] - s.begin().first);
      |                                   ^~~~~