제출 #590013

#제출 시각아이디문제언어결과실행 시간메모리
590013AlesL0전선 연결 (IOI17_wiring)C++17
0 / 100
262 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct edge { ll len, red, blue; }; bool cmp(edge a, edge b){ return (a.len < b.len); } const ll INF = 1e10; long long min_total_length(std::vector<int> r, std::vector<int> b){ ll n = r.size(), m = b.size(); vector <edge> e; for (int i = 0; i < r.size(); i++){ for (int j = 0; j < b.size(); j++)e.push_back({abs(r[i]-b[j]), i, j}); } vector <bool> bred(r.size(), 0), bblue(b.size(), 0); ll s = 0; sort(e.begin(), e.end(), cmp); for (auto x : e){ if (!bred[x.red] && !bblue[x.blue]){ bred[x.red] = 1; bblue[x.blue] = 1; s += x.len; } } vector <ll> closestr(n, INF), closestb(m, INF); for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ closestr[i] = min(closestr[i], (long long)abs(r[i]-b[j])); closestb[j] = min(closestb[j], (long long)abs(r[i]-b[j])); } } if (n > m){ for (int i = 0; i < r.size(); i++)if (!bred[i])s += closestr[i]; } else { for (int i = 0; i < b.size(); i++)if (!bblue[i])s += closestb[i]; } return s; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < r.size(); i++){
      |                     ~~^~~~~~~~~~
wiring.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = 0; j < b.size(); j++)e.push_back({abs(r[i]-b[j]), i, j});
      |                         ~~^~~~~~~~~~
wiring.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int i = 0; i < r.size(); i++)if (!bred[i])s += closestr[i];
      |                         ~~^~~~~~~~~~
wiring.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int i = 0; i < b.size(); i++)if (!bblue[i])s += closestb[i];
      |                         ~~^~~~~~~~~~
#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...