답안 #136633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136633 2019-07-25T23:03:47 Z DanerZein Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
245 ms 165352 KB
#include "railroad.h"
#include <bits/stdc++.h>
#define MAX 10000000000
using namespace std;
long long dp[100][100000];
long long dist[100][100];
long long l,tam;
long long tsp(){
  for(int mask=0;mask<(1<<tam);mask++){
    for(int i=0;i<tam;i++){
      if(mask==(1<<i)){
	  dp[i][mask]=0;
      }
	else{
          if(mask&(1<<i)){
    	     dp[i][mask]=MAX;
	     for(int j=0;j<tam;j++){
	       int newmask=mask^(1<<i);
	       if(newmask&(1<<j))
	       dp[i][mask]=min(dp[i][mask],dist[i][j]+dp[j][newmask]);
	     }
	  }
	}
    }
  }
    long long r=MAX;
    for(int i=0;i<tam;i++){
      r=min(r,dp[i][(1<<tam)-1]);
    }
      return r;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
   tam=s.size();
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      int r1=t[i]-s[j];
      int r2=t[j]-s[i];
      // cout<<t[i]<<" "<<s[j]<<" "<<t[j]<<" "<<s[i]<<endl;
      r1=max(r1,0);
      r2=max(r2,0);
      dist[i][j]=r1;
      dist[j][i]=r2;
    }
  }
  long long r=tsp();
  /*for(int i=0;i<tam;i++){
    for(int j=0;j<(1<<tam);j++){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
  return r;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i++){
               ~^~~~~~~~~
railroad.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=i+1;j<s.size();j++){
                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 376 KB n = 2
3 Correct 2 ms 376 KB n = 2
4 Correct 2 ms 376 KB n = 2
5 Correct 2 ms 376 KB n = 2
6 Correct 2 ms 376 KB n = 2
7 Correct 2 ms 376 KB n = 3
8 Correct 2 ms 376 KB n = 3
9 Correct 2 ms 376 KB n = 3
10 Correct 2 ms 376 KB n = 8
11 Correct 2 ms 380 KB n = 8
12 Correct 2 ms 376 KB n = 8
13 Correct 2 ms 380 KB n = 8
14 Correct 2 ms 380 KB n = 8
15 Correct 2 ms 376 KB n = 8
16 Correct 2 ms 376 KB n = 8
17 Correct 2 ms 376 KB n = 8
18 Correct 2 ms 376 KB n = 8
19 Correct 2 ms 380 KB n = 3
20 Correct 2 ms 376 KB n = 7
21 Correct 4 ms 376 KB n = 8
22 Correct 2 ms 376 KB n = 8
23 Correct 6 ms 376 KB n = 8
24 Correct 2 ms 376 KB n = 8
25 Correct 2 ms 376 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 376 KB n = 2
3 Correct 2 ms 376 KB n = 2
4 Correct 2 ms 376 KB n = 2
5 Correct 2 ms 376 KB n = 2
6 Correct 2 ms 376 KB n = 2
7 Correct 2 ms 376 KB n = 3
8 Correct 2 ms 376 KB n = 3
9 Correct 2 ms 376 KB n = 3
10 Correct 2 ms 376 KB n = 8
11 Correct 2 ms 380 KB n = 8
12 Correct 2 ms 376 KB n = 8
13 Correct 2 ms 380 KB n = 8
14 Correct 2 ms 380 KB n = 8
15 Correct 2 ms 376 KB n = 8
16 Correct 2 ms 376 KB n = 8
17 Correct 2 ms 376 KB n = 8
18 Correct 2 ms 376 KB n = 8
19 Correct 2 ms 380 KB n = 3
20 Correct 2 ms 376 KB n = 7
21 Correct 4 ms 376 KB n = 8
22 Correct 2 ms 376 KB n = 8
23 Correct 6 ms 376 KB n = 8
24 Correct 2 ms 376 KB n = 8
25 Correct 2 ms 376 KB n = 8
26 Correct 2 ms 376 KB n = 8
27 Correct 2 ms 376 KB n = 8
28 Correct 2 ms 376 KB n = 8
29 Correct 48 ms 7312 KB n = 16
30 Correct 46 ms 7288 KB n = 16
31 Correct 46 ms 7284 KB n = 16
32 Correct 45 ms 7288 KB n = 16
33 Correct 45 ms 7308 KB n = 16
34 Correct 44 ms 7288 KB n = 16
35 Correct 45 ms 7216 KB n = 16
36 Correct 22 ms 3704 KB n = 15
37 Correct 2 ms 376 KB n = 8
38 Correct 45 ms 7288 KB n = 16
39 Correct 45 ms 7416 KB n = 16
40 Correct 2 ms 376 KB n = 9
41 Correct 45 ms 7292 KB n = 16
42 Correct 44 ms 7288 KB n = 16
43 Correct 44 ms 7288 KB n = 16
44 Correct 2 ms 376 KB n = 9
45 Correct 22 ms 3752 KB n = 15
46 Correct 44 ms 7276 KB n = 16
47 Correct 45 ms 7288 KB n = 16
48 Correct 45 ms 7260 KB n = 16
# 결과 실행 시간 메모리 Grader output
1 Runtime error 245 ms 165352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 376 KB n = 2
3 Correct 2 ms 376 KB n = 2
4 Correct 2 ms 376 KB n = 2
5 Correct 2 ms 376 KB n = 2
6 Correct 2 ms 376 KB n = 2
7 Correct 2 ms 376 KB n = 3
8 Correct 2 ms 376 KB n = 3
9 Correct 2 ms 376 KB n = 3
10 Correct 2 ms 376 KB n = 8
11 Correct 2 ms 380 KB n = 8
12 Correct 2 ms 376 KB n = 8
13 Correct 2 ms 380 KB n = 8
14 Correct 2 ms 380 KB n = 8
15 Correct 2 ms 376 KB n = 8
16 Correct 2 ms 376 KB n = 8
17 Correct 2 ms 376 KB n = 8
18 Correct 2 ms 376 KB n = 8
19 Correct 2 ms 380 KB n = 3
20 Correct 2 ms 376 KB n = 7
21 Correct 4 ms 376 KB n = 8
22 Correct 2 ms 376 KB n = 8
23 Correct 6 ms 376 KB n = 8
24 Correct 2 ms 376 KB n = 8
25 Correct 2 ms 376 KB n = 8
26 Correct 2 ms 376 KB n = 8
27 Correct 2 ms 376 KB n = 8
28 Correct 2 ms 376 KB n = 8
29 Correct 48 ms 7312 KB n = 16
30 Correct 46 ms 7288 KB n = 16
31 Correct 46 ms 7284 KB n = 16
32 Correct 45 ms 7288 KB n = 16
33 Correct 45 ms 7308 KB n = 16
34 Correct 44 ms 7288 KB n = 16
35 Correct 45 ms 7216 KB n = 16
36 Correct 22 ms 3704 KB n = 15
37 Correct 2 ms 376 KB n = 8
38 Correct 45 ms 7288 KB n = 16
39 Correct 45 ms 7416 KB n = 16
40 Correct 2 ms 376 KB n = 9
41 Correct 45 ms 7292 KB n = 16
42 Correct 44 ms 7288 KB n = 16
43 Correct 44 ms 7288 KB n = 16
44 Correct 2 ms 376 KB n = 9
45 Correct 22 ms 3752 KB n = 15
46 Correct 44 ms 7276 KB n = 16
47 Correct 45 ms 7288 KB n = 16
48 Correct 45 ms 7260 KB n = 16
49 Runtime error 245 ms 165352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -