제출 #794283

#제출 시각아이디문제언어결과실행 시간메모리
794283TheSahib전선 연결 (IOI17_wiring)C++14
13 / 100
21 ms1876 KiB
#include "wiring.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int MAX = 1e3 + 5; ll dp[MAX][MAX]; long long min_total_length(vector<int> r, vector<int> b) { if(b[0] > r.back()){ if(r.size() < b.size()){ swap(r, b); reverse(b.begin(), b.end()); } int p1 = 0, p2 = 0; long long ans = 0; while(p1 != r.size() && p2 != b.size()){ ans += abs(r[p1] - b[p2]); p1++; p2++; } while(p1 != r.size()){ ans += min(abs(r[p1] - b[0]), abs(r[p1] - b.back())); p1++; } return ans; } for (int i = 1; i <= r.size(); i++) { for (int j = 1; j <= b.size(); j++) { dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + abs(r[i - 1] - b[j - 1]); } } return dp[r.size()][b.size()]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         while(p1 != r.size() && p2 != b.size()){
      |               ~~~^~~~~~~~~~~
wiring.cpp:20:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         while(p1 != r.size() && p2 != b.size()){
      |                                 ~~~^~~~~~~~~~~
wiring.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         while(p1 != r.size()){
      |               ~~~^~~~~~~~~~~
wiring.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 1; i <= r.size(); i++)
      |                     ~~^~~~~~~~~~~
wiring.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j = 1; j <= b.size(); j++)
      |                         ~~^~~~~~~~~~~
#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...