Submission #71399

# Submission time Handle Problem Language Result Execution time Memory
71399 2018-08-24T13:16:33 Z Kmcode Wiring (IOI17_wiring) C++14
0 / 100
136 ms 49028 KB
#include<bits/stdc++.h>
//#include "books.h"
using namespace std;

#define MAX 100002
int n;
long long int dp[MAX][60];
long long min_total_length(std::vector<int> r, std::vector<int> b) {
	for(int i=0;i<r.size();i++){
		for(int j=0;j<60;j++){
			dp[i][j]=LLONG_MAX;
		}
	}
	dp[0][20]=abs(r[0]-b[0]);
	for(int i=0;i<r.size();i++){
		for(int j1=0;j1<50;j1++){
			int j=i+j1-20;
			if(j<0||j>=b.size())continue;
			if(dp[i][j1]==LLONG_MAX)continue;
			if(i+1<r.size()){
				int base=i+1-20;
				dp[i+1][j-base]=min(dp[i+1][j-base],dp[i][j1]+abs(r[i+1]-b[j]));
			}
			if(j+1<b.size()){
				int base=i-20;
				dp[i][j+1-base]=min(dp[i][j+1-base],dp[i][j1]+abs(r[i]-b[j+1]));
			}
			if(i+1<r.size()&&j+1<b.size()){
				int base=i+1-20;
				dp[i+1][j+1-base]=min(dp[i+1][j+1-base],dp[i][j1]+abs(r[i+1]-b[j+1]));
			}
		}
	}
	int t=r.size()-1;
	return dp[r.size()-1][(int)b.size()-1-(t)+20];
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:18:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j<0||j>=b.size())continue;
            ~^~~~~~~~~~
wiring.cpp:20:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()){
       ~~~^~~~~~~~~
wiring.cpp:24:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:28:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:28:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
                     ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Incorrect 2 ms 640 KB 3rd lines differ - on the 1st token, expected: '705547', found: '715667'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 676 KB Output is correct
2 Incorrect 2 ms 676 KB 3rd lines differ - on the 1st token, expected: '84383', found: '9223372036854775807'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 676 KB Output is correct
2 Correct 3 ms 676 KB Output is correct
3 Incorrect 136 ms 49020 KB 3rd lines differ - on the 1st token, expected: '1068938599', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 49020 KB Output is correct
2 Incorrect 108 ms 49028 KB 3rd lines differ - on the 1st token, expected: '373710605', found: '2190853081'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Incorrect 2 ms 640 KB 3rd lines differ - on the 1st token, expected: '705547', found: '715667'
9 Halted 0 ms 0 KB -