이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <wiring.h>
using namespace std;
#define ll long long
//#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> x, y;
map<int,bool> vis[100010];
map<int,ll> memo[100010];
ll sol(int a,int b){
if(a==x.size() && b==y.size())return 0;
if(vis[a][b])return memo[a][b];
vis[a][b]=1;
if(a==x.size()){
ll t=0;
for(int i=b;i<y.size();i++)t+=abs(y[i]-x.back());
return memo[a][b]=t;
}
if(b==y.size()){
ll t=0;
for(int i=a;i<x.size();i++)t+=abs(x[i]-y.back());
return memo[a][b]=t;
}
ll best=1e16;
best=min(best,sol(a+1,b+1)+abs(x[a]-y[b]));
if(a>0)best=min(best,sol(a,b+1)+abs(x[a-1]-y[b]));
if(b>0)best=min(best,sol(a+1,b)+abs(x[a]-y[b-1]));
return memo[a][b]=best;
}
long long min_total_length(std::vector<int> r, std::vector<int> b) {
x=r;y=b;
return sol(0,0);
}
컴파일 시 표준 에러 (stderr) 메시지
wiring.cpp: In function 'long long int sol(int, int)':
wiring.cpp:11:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | if(a==x.size() && b==y.size())return 0;
| ~^~~~~~~~~~
wiring.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | if(a==x.size() && b==y.size())return 0;
| ~^~~~~~~~~~
wiring.cpp:14:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | if(a==x.size()){
| ~^~~~~~~~~~
wiring.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=b;i<y.size();i++)t+=abs(y[i]-x.back());
| ~^~~~~~~~~
wiring.cpp:19:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | if(b==y.size()){
| ~^~~~~~~~~~
wiring.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=a;i<x.size();i++)t+=abs(x[i]-y.back());
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |