답안 #994841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994841 2024-06-08T07:22:45 Z SuPythony Roller Coaster Railroad (IOI16_railroad) C++17
11 / 100
2000 ms 524288 KB
#include <bits/stdc++.h>
#include "railroad.h"
using namespace std;
typedef long long ll;

vector<vector<pair<int,ll>>> al;
vector<int> vis;
ll c;
int n;
int tot;
ll mn=1e18;

void dfs(int u) {
    vis[u]=1;
    n++;
    if (n==tot) {
        mn=min(mn,c);
    }
    for (auto i: al[u]) {
        if (vis[i.first]) continue;
        c+=i.second;
        dfs(i.first);
        c-=i.second;
    }
    vis[u]=0;
    n--;
}

ll plan_roller_coaster(vector<int> s, vector<int> t) {
    al.assign(s.size(),vector<pair<int,ll>>());
    tot=s.size();
    for (int i=0; i<s.size(); i++) {
        for (int j=0; j<s.size(); j++) {
            if (i==j) continue;
            ll w=0;
            if (t[i]>s[j]) w=t[i]-s[j];
            al[i].push_back({j,w});
        }
    }
    mn=1e18;
    for (int i=0; i<s.size(); i++) {
        vis.assign(s.size(),0);
        c=0;
        n=0;
        dfs(i);
    }
    return mn;
};

Compilation message

railroad.cpp: In function 'll plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0; i<s.size(); i++) {
      |                   ~^~~~~~~~~
railroad.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j=0; j<s.size(); j++) {
      |                       ~^~~~~~~~~
railroad.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i=0; i<s.size(); i++) {
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Correct 1 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 0 ms 348 KB n = 3
9 Correct 1 ms 348 KB n = 3
10 Correct 2 ms 348 KB n = 8
11 Correct 1 ms 432 KB n = 8
12 Correct 1 ms 344 KB n = 8
13 Correct 1 ms 348 KB n = 8
14 Correct 1 ms 348 KB n = 8
15 Correct 2 ms 348 KB n = 8
16 Correct 1 ms 348 KB n = 8
17 Correct 2 ms 432 KB n = 8
18 Correct 2 ms 348 KB n = 8
19 Correct 1 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 2 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 1 ms 604 KB n = 8
24 Correct 1 ms 348 KB n = 8
25 Correct 1 ms 348 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Correct 1 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 0 ms 348 KB n = 3
9 Correct 1 ms 348 KB n = 3
10 Correct 2 ms 348 KB n = 8
11 Correct 1 ms 432 KB n = 8
12 Correct 1 ms 344 KB n = 8
13 Correct 1 ms 348 KB n = 8
14 Correct 1 ms 348 KB n = 8
15 Correct 2 ms 348 KB n = 8
16 Correct 1 ms 348 KB n = 8
17 Correct 2 ms 432 KB n = 8
18 Correct 2 ms 348 KB n = 8
19 Correct 1 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 2 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 1 ms 604 KB n = 8
24 Correct 1 ms 348 KB n = 8
25 Correct 1 ms 348 KB n = 8
26 Correct 1 ms 348 KB n = 8
27 Correct 1 ms 436 KB n = 8
28 Correct 1 ms 348 KB n = 8
29 Execution timed out 2094 ms 348 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 455 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB n = 2
2 Correct 0 ms 348 KB n = 2
3 Correct 0 ms 348 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 0 ms 348 KB n = 2
6 Correct 1 ms 348 KB n = 2
7 Correct 0 ms 348 KB n = 3
8 Correct 0 ms 348 KB n = 3
9 Correct 1 ms 348 KB n = 3
10 Correct 2 ms 348 KB n = 8
11 Correct 1 ms 432 KB n = 8
12 Correct 1 ms 344 KB n = 8
13 Correct 1 ms 348 KB n = 8
14 Correct 1 ms 348 KB n = 8
15 Correct 2 ms 348 KB n = 8
16 Correct 1 ms 348 KB n = 8
17 Correct 2 ms 432 KB n = 8
18 Correct 2 ms 348 KB n = 8
19 Correct 1 ms 348 KB n = 3
20 Correct 1 ms 348 KB n = 7
21 Correct 2 ms 348 KB n = 8
22 Correct 1 ms 348 KB n = 8
23 Correct 1 ms 604 KB n = 8
24 Correct 1 ms 348 KB n = 8
25 Correct 1 ms 348 KB n = 8
26 Correct 1 ms 348 KB n = 8
27 Correct 1 ms 436 KB n = 8
28 Correct 1 ms 348 KB n = 8
29 Execution timed out 2094 ms 348 KB Time limit exceeded
30 Halted 0 ms 0 KB -