제출 #415593

#제출 시각아이디문제언어결과실행 시간메모리
415593cfalas전선 연결 (IOI17_wiring)C++14
13 / 100
189 ms25928 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std; #define mp make_pair #define INF 10000000 #define MOD 1000000007 #define MID ((l+r)/2) #define HASHMOD 2305843009213693951 #define ll long long #define ull unsigned long long #define F first #define S second typedef pair<ll, ll> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef map<int, int> mii; #define EPS 1e-6 #define FOR(i,n) for(int i=0;i<((int)(n));i++) #define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++) #define FOA(v, a) for(auto v : a) map<int, int> used; long long min_total_length(std::vector<int> r, std::vector<int> b) { ll ans=0; int cnt=0; vector<int> a[2] = {r,b}; set<ii> all; set<int> col[2]; FOA(v, a[0]) all.insert({v, 0}), col[0].insert(v); FOA(v, a[1]) all.insert({v, 1}), col[1].insert(v); FOA(v,all){ auto it = col[1-v.S].lower_bound(v.F); if(it==col[1-v.S].end()){ // eneshi unused, pame se used int d1=MOD, d2=MOD; auto it1 = lower_bound(a[1-v.S].begin(), a[1-v.S].end(), v.F); auto it2 = lower_bound(a[1-v.S].begin(), a[1-v.S].end(), v.F); it2--; if(it1!=a[1-v.S].end()) d1 =abs(v.F - *it1); if(it1!=a[1-v.S].begin()) d2 = abs(v.F - *it2); //cout<<v.F<<" "<<d1<<" "<<d2<<endl; ans += min(d1, d2); } else{ //cout<<v.F<<" "<<*it<<endl; ans+= abs(v.F - *it); all.erase({*it, 1-v.S}); col[1-v.S].erase(*it); } } return ans; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:27:6: warning: unused variable 'cnt' [-Wunused-variable]
   27 |  int cnt=0;
      |      ^~~
#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...