답안 #848906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848906 2023-09-13T17:08:38 Z Mr_Ph 경주 (Race) (IOI11_race) C++14
21 / 100
3000 ms 11348 KB
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>vs;
vector<int>vs1;
vector<vector<pair<int,int>>>adj;
int ans=1e9;
int pog=0;
void dfs(int node,int lol,int sum)
{
    vs[node]=true;
    if(sum>pog)
        return;
    if(sum==pog)
    {
        ans=min(ans,lol);
        return;
    }
    for(auto i:adj[node])
    {
        if(!vs[i.first]){
           // cout<<node<<" "<<i.first<<" "<<i.second<<endl;
            dfs(i.first,lol+1,sum+i.second);
        }
    }
}
int best_path(int n, int k, int h[][2], int l[])
{
    pog=k;
    adj.resize(n+1);
    vs.resize(n+1);
    vs1=vs;
    for(int i=0;i<n-1;i++)
    {
       // cout<<h[i][0]<<" "<<h[i][1]<<" "<<l[i]<<endl;
        adj[h[i][0]].push_back({h[i][1],l[i]});
        adj[h[i][1]].push_back({h[i][0],l[i]});
    }
    for(int i=0;i<n;i++)
    {
        vs=vs1;
        dfs(i,0,0);
        //cout<<ans<<endl;
    }
    if(ans==1e9)ans=-1;
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2592 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2592 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2592 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2592 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 7 ms 2648 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 7 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 3 ms 2392 KB Output is correct
29 Correct 5 ms 2392 KB Output is correct
30 Correct 5 ms 2396 KB Output is correct
31 Correct 7 ms 2392 KB Output is correct
32 Correct 9 ms 2392 KB Output is correct
33 Correct 7 ms 2392 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 6 ms 2396 KB Output is correct
38 Correct 7 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2592 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2592 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Execution timed out 3031 ms 11348 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2592 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2592 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 7 ms 2648 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 7 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 3 ms 2392 KB Output is correct
29 Correct 5 ms 2392 KB Output is correct
30 Correct 5 ms 2396 KB Output is correct
31 Correct 7 ms 2392 KB Output is correct
32 Correct 9 ms 2392 KB Output is correct
33 Correct 7 ms 2392 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 6 ms 2396 KB Output is correct
38 Correct 7 ms 2392 KB Output is correct
39 Execution timed out 3031 ms 11348 KB Time limit exceeded
40 Halted 0 ms 0 KB -