Submission #71409

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

#define MAX 100002
int n;
long long int dp[MAX][110];
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<100;j++){
			dp[i][j]=LLONG_MAX;
		}
	}
	int x=50;
	dp[0][x]=abs(r[0]-b[0]);
	for(int i=0;i<r.size();i++){
		for(int j1=0;j1<100;j1++){
			int j=i+j1-x;
			if(j<0||j>=b.size())continue;
			if(dp[i][j1]==LLONG_MAX)continue;
			long long int val=dp[i][j1];
			if(i+1<r.size()){
				int base=i+1-x;
				if(j-base>=0)dp[i+1][j-base]=min(dp[i+1][j-base],val+(long long int)abs(r[i+1]-b[j]));
			}
			if(j+1<b.size()){
				int base=i-x;
				if(j+1-base>=0)dp[i][j+1-base]=min(dp[i][j+1-base],val+(long long int)abs(r[i]-b[j+1]));
			}
			if(i+1<r.size()&&j+1<b.size()){
				int base=i+1-x;
				if(j+1-base>=0)dp[i+1][j+1-base]=min(dp[i+1][j+1-base],val+(long long int)abs(r[i+1]-b[j+1]));
			}
		}
	}
	int t=r.size()-1;
	return dp[r.size()-1][x];
}

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:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:19:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j<0||j>=b.size())continue;
            ~^~~~~~~~~~
wiring.cpp:22:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()){
       ~~~^~~~~~~~~
wiring.cpp:26:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:30:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:30:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
                     ~~~^~~~~~~~~
wiring.cpp:36:6: warning: unused variable 't' [-Wunused-variable]
  int t=r.size()-1;
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB 3rd lines differ - on the 1st token, expected: '25859', found: '9223372036854775807'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 484 KB 3rd lines differ - on the 1st token, expected: '904', found: '9223372036854775807'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Incorrect 263 ms 88220 KB 3rd lines differ - on the 1st token, expected: '1068938599', found: '255686279937'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 88220 KB Output is correct
2 Incorrect 201 ms 88220 KB 3rd lines differ - on the 1st token, expected: '373710605', found: '2185845351'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB 3rd lines differ - on the 1st token, expected: '25859', found: '9223372036854775807'
2 Halted 0 ms 0 KB -