제출 #33898

#제출 시각아이디문제언어결과실행 시간메모리
33898mohammad_kilani전선 연결 (IOI17_wiring)C++14
20 / 100
43 ms6324 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; const int N = 500; vector<int> r , b; long long dp[N][N]; int n , m; long long solve(int i,int j){ if(i == n && j == m) return 0; if(j == m) return 1e18; if(dp[i][j] != -1) return dp[i][j]; dp[i][j] = min(solve(i+1,j),min(solve(i,j+1),solve(i+1,j+1))) + abs(r[i] - b[j]); return dp[i][j]; } long long min_total_length(std::vector<int> R, std::vector<int> B) { memset(dp,-1,sizeof(dp)); r = R; b = B; n = r.size(); m = b.size(); if(n <= 500 && m <= 500) return solve(0,0); if(r.back() < b[0]){ long long sum = 0 ; int idx = 0 ; int idx2 = 0; for(int i=0;i<min(n,m);i++) sum += abs(r[idx++] - b[idx2++]); for(int i=idx;i<r.size();i++) sum+= abs(r[i] - b[0]); for(int i=idx2;i<b.size();i++) sum+= abs(b[i] - r.back()); return sum; } return rand(); }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=idx;i<r.size();i++) sum+= abs(r[i] - b[0]);
                  ^
wiring.cpp:32:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=idx2;i<b.size();i++) sum+= abs(b[i] - r.back());
                   ^
#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...