Submission #38934

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
389342018-01-08 07:10:42moonrabbit2Wiring (IOI17_wiring)C++14
7 / 100
56 ms11008 KiB
#include "wiring.h"
#include <bits/stdc++.h>
#define N 100005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll,int>P;
int n,m,k;
P c[N*2];
ll dp[2*N],diff[N],mdist[N],p[2];
int plc[N],appear[2*N],amt;
ll min_total_length(vector<int> a,vector<int> b) {
n=a.size(),m=b.size(),k=n+m;
for(int i=0,j=0;i+j<k;){
if(j>=m||i<n&&a[i]<b[j]){
c[i+j+1]={(ll)a[i],0};
i++;
}
else{
c[i+j+1]={(ll)b[j],1};
j++;
}
}
for(int i=1;i<=k;i++)
mdist[i]=1e9+10;
p[0]=p[1]=-1;
for(int i=1;i<=k;i++){
if(p[!c[i].s]!=-1)
mdist[i]=min(mdist[i],c[i].f-c[p[!c[i].s]].f);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:16:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if(j>=m||i<n&&a[i]<b[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...