Submission #101960

# Submission time Handle Problem Language Result Execution time Memory
101960 2019-03-21T07:44:57 Z tim25871014 Wiring (IOI17_wiring) C++17
0 / 100
2 ms 384 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

long long min_total_length(vector<int> r, vector<int> b){
    int n=r.size(),m=b.size();
    int minn=min(n,m);
    
    if(n<=200 && m<=200){
        
        int dp[210][210];
        dp[0][0]=abs(r[0]-b[0]);
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                int minn=2147483647;
                if(i*j) minn=min(minn,dp[i-1][j-1]);
                if(i) minn=min(minn,dp[i-1][j]);
                if(j) minn=min(minn,dp[i][j-1]);
                
                minn+=abs(r[i]-b[j]);
                
                dp[i][j]=minn;
            }
        return dp[n-1][m-1];
    }
    
    long long ans=0;
    for(int i=0;i<minn;i++)
        ans+=b[m-i-1]-r[i];
    
    for(int i=minn;i<n;i++)
        ans+=b[0]-r[i];
    
    for(int i=minn;i<m;i++)
        ans+=b[m-i-1]-r[n-1];
    
    return ans;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:16:21: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
                 if(i*j) minn=min(minn,dp[i-1][j-1]);
                    ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '25859', found: '-2147457790'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '904', found: '-2147482745'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '316', found: '-2147483333'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '27', found: '-2147483622'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '25859', found: '-2147457790'
2 Halted 0 ms 0 KB -