Submission #738365

# Submission time Handle Problem Language Result Execution time Memory
738365 2023-05-08T15:13:32 Z Elvin_Fritl Wiring (IOI17_wiring) C++17
0 / 100
1 ms 340 KB
#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;
        s.insert({r[i],1});
    }
    int j=0,n=(int)b.size()+(int)r.size();
    
    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()->second == 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});
            s1.erase(s1.begin());
        }
    }
    
    return res;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:12:9: warning: unused variable 'j' [-Wunused-variable]
   12 |     int j=0,n=(int)b.size()+(int)r.size();
      |         ^
wiring.cpp:12:13: warning: unused variable 'n' [-Wunused-variable]
   12 |     int j=0,n=(int)b.size()+(int)r.size();
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21229'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21229'
2 Halted 0 ms 0 KB -