제출 #1073477

#제출 시각아이디문제언어결과실행 시간메모리
1073477hasan2006전선 연결 (IOI17_wiring)C++17
13 / 100
31 ms2396 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; if(a.size() > b.size()) swap(a , b); int f , l, r , i , j , x , y , n , m; ll s = 0; 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; }

컴파일 시 표준 에러 (stderr) 메시지

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(i = 0; i < d1.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(i = 0; i < d2.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:29:22: warning: unused variable 'j' [-Wunused-variable]
   29 |   int f , l, r , i , j , x , y , n , m;
      |                      ^
wiring.cpp:29:30: warning: unused variable 'y' [-Wunused-variable]
   29 |   int f , l, r , i , j , x , y , n , m;
      |                              ^
wiring.cpp:29:34: warning: unused variable 'n' [-Wunused-variable]
   29 |   int f , l, r , i , j , x , y , n , m;
      |                                  ^
wiring.cpp:29:38: warning: unused variable 'm' [-Wunused-variable]
   29 |   int 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...