제출 #200415

#제출 시각아이디문제언어결과실행 시간메모리
200415HellAngel전선 연결 (IOI17_wiring)C++14
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; /// dont use define int long long void Minimize(ll &a, const ll &b) { a = min(a, b); } ll min_total_length(vector<int> r, vector<int> b) { vector<vector<ll>> dp(0), prf(0); vector<pair<ll, ll>> vt; for(auto i: r) vt.emplace_back(i, 0); for(auto i: b) vt.emplace_back(i, 1); sort(vt.begin(), vt.end()); int cur = 0; while(cur < vt.size()) { int nxt = cur; vector<ll> nprf = {0}; for(; nxt < vt.size() && vt[nxt].second == vt[cur].second; nxt++) { nprf.push_back(vt[nxt].first + nprf.back()); } cur = nxt; vector<ll> blank(nprf.size(), (ll)1e17); dp.push_back(blank); prf.push_back(nprf); } auto Get = [&](ll x, ll y) { ll ans = prf[x][y] - prf[x][y - 1]; return ans; }; dp[0][0] = 0; for(int i = 0; i < dp.size(); i++) { for(int j = 0; j + 1 < dp[i].size(); j++) { if(i > 0) Minimize(dp[i][j + 1], dp[i][j] + Get(i, j + 1) - Get(i - 1, prf[i - 1].size() - 1)); if(i + 1 < dp.size()) { if(prf[i].size() - j - 1 <= prf[i + 1].size() - 1) { Minimize(dp[i + 1][prf[i].size() - j - 1], dp[i][j] + prf[i + 1][prf[i].size() - j - 1] - prf[i][prf[i].size() - 1] + prf[i][j]); } Minimize(dp[i][j + 1], dp[i][j] - Get(i, j) + Get(i + 1, 1)); } } if(i + 1 < dp.size()) Minimize(dp[i + 1][0], dp[i].back()); else return dp[i].back(); } return 0; }

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

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(cur < vt.size())
           ~~~~^~~~~~~~~~~
wiring.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(; nxt < vt.size() && vt[nxt].second == vt[cur].second; nxt++)
               ~~~~^~~~~~~~~~~
wiring.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < dp.size(); i++)
                    ~~^~~~~~~~~~~
wiring.cpp:39:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j + 1 < dp[i].size(); j++)
                        ~~~~~~^~~~~~~~~~~~~~
wiring.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(i + 1 < dp.size()) 
                ~~~~~~^~~~~~~~~~~
wiring.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i + 1 < dp.size()) Minimize(dp[i + 1][0], dp[i].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...