Submission #1073453

#TimeUsernameProblemLanguageResultExecution timeMemory
1073453hasan2006Wiring (IOI17_wiring)C++17
0 / 100
17 ms3420 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" ll min_total_length(vector<int> a, vector<int> b){ a.pb(2e9); b.pb(2e9); deque<int>d1 , d2; int s = 0 , f , l, r , i , j , x , y , n , m; f = a.size() + b.size() - 2; l = r= 0; while(f--){ if(a[l] <= b[r]){ if(d2.size() > 0) s += a[l] - d2.back() , d2.pop_back(); else d1.pb(a[l]); l++; }else { if(d1.size() > 0) s += b[r] - d1.back() , d1.pop_back(); else d2.pb(b[r]); r++; } } l = 0; for(i = 0; i < d1.size(); i++){ while(b[l] < d1[i]) l++; x = b[l] - d1[i]; if(l) x = min(x ,d1[i] - b[l - 1]); s += x; } l = 0; for(i = 0; i < d2.size(); i++){ while(a[l] < d2[i]) l++; x = a[l] - d2[i]; if(l) x = min(x ,d2[i] - a[l - 1]); s += x; } return s; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(i = 0; i < d1.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(i = 0; i < d2.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:26:32: warning: unused variable 'j' [-Wunused-variable]
   26 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                ^
wiring.cpp:26:40: warning: unused variable 'y' [-Wunused-variable]
   26 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                        ^
wiring.cpp:26:44: warning: unused variable 'n' [-Wunused-variable]
   26 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                            ^
wiring.cpp:26:48: warning: unused variable 'm' [-Wunused-variable]
   26 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...