Submission #738395

#TimeUsernameProblemLanguageResultExecution timeMemory
738395Elvin_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<int>s,s1;
    vector<int>chek((int)b.size() + (int)r.size(),0);
    for(int i=0;i<(int)r.size();i++){
        s.insert(r[i]);
    }

    long long res=0;

    for(int i=0;i<(int)b.size();i++){
        s1.insert(b[i]);
        auto it=s.upper_bound(b[i]);
        auto it2=it;
        if(it!=s.begin()){
            it2--;
        }
        int tmp1=abs(*it - b[i]);
        int tmp2=abs(*it2 - b[i]));
        if(tmp1>tmp2){
            chek[*it2]=1;
            res+=tmp2;
        }
        else if(tmp1<tmp2){
            chek[*it]=1;
            res+=tmp1;
        }
        else{
            if(chek[*it]==1){
                chek[*it2]=1;
                res+=tmp2;
            }
            else{
                chek[*it]=1;
                res+=tmp;
            }
        }
    }

    for(int i=0;i<(int)r.size();i++){
        if(chek[r[i]]==0){
            auto it=s1.upper_bound(r[i]);
            auto it2=it;
            if(it!=s1.begin()){
                it2--;
            }
            int tmp1=abs(*it - r[i]);
            int tmp2=abs(*it2 - r[i]));
            if(tmp1>tmp2){
                chek[*it2]=1;
                res+=tmp2;
            }
            else if(tmp1<tmp2){
                chek[*it]=1;
                res+=tmp1;
            }
            else{
                if(chek[*it]==1){
                    chek[*it2]=1;
                    res+=tmp2;
                }
                else{
                    chek[*it]=1;
                    res+=tmp;
                }
            }
        }
    }

    return res;
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:22:34: error: expected ',' or ';' before ')' token
   22 |         int tmp2=abs(*it2 - b[i]));
      |                                  ^
wiring.cpp:38:22: error: 'tmp' was not declared in this scope; did you mean 'tmp2'?
   38 |                 res+=tmp;
      |                      ^~~
      |                      tmp2
wiring.cpp:51:38: error: expected ',' or ';' before ')' token
   51 |             int tmp2=abs(*it2 - r[i]));
      |                                      ^
wiring.cpp:67:26: error: 'tmp' was not declared in this scope; did you mean 'tmp2'?
   67 |                     res+=tmp;
      |                          ^~~
      |                          tmp2