답안 #805689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805689 2023-08-03T20:29:09 Z Mouad_ouj 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 14380 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int> >> adj;
vector<bool> vis;
vector<int> t,d;
int n,m,l;
void dfs(int node)
{
    vis[node]=true;
    int k=adj[node].size();
    for(int x=0;x<k;x++)
    {
        int to=adj[node][x].first;
        if(!vis[to])
        dfs(to);
    }
}
void dfs3(int node,int dis[])
{
    vis[node]=true;
    int k=adj[node].size();
    for(int x=0;x<k;x++)
    {
        int to=adj[node][x].first;
        if(!vis[to])
        {
        dis[to]=dis[node]+adj[node][x].second;    
        dfs3(to,dis);
        }
    }
}
int get(int y)
{
    int dis[n+1]={0},disa[n+1]={0},disb[n+1]={0},a=y,b=y,cur=0;
    vis.assign(n+1,false);
    if(adj[y].size()!=0)
    dfs3(y,dis);
    else 
    return 0;
    for(int x=1;x<=n;x++)
    {
        if(cur<=dis[x] && x!=y)
        {
            a=x;
            cur=dis[x];
        }
    }    
    vis.assign(n+1,false);
    dfs3(a,disa);
    cur=0;
    for(int x=1;x<=n;x++)
    {
        if(cur<disa[x] && x!=a)
        {
            b=x;
            cur=disa[x];
        }
    }
    vis.assign(n+1,false);
    dfs3(b,disb);
    int ans=disb[a];
    for(int x=1;x<=n;x++)
    {
        if(disa[x]!=0 || disb[x]!=0)
        ans=min(ans,max(disa[x],disb[x]));
    }
    d.push_back(disa[b]);
    return ans;
}
int travelTime(int ne,int me,int le,int u[],int v[],int te[])
{
    n=ne;m=me;l=le;
    adj.resize(n+1);
    vis.assign(n+1,false);
    for(int x=0;x<m;x++)
    {
        adj[u[x]+1].push_back(make_pair(v[x]+1,te[x]));
        adj[v[x]+1].push_back(make_pair(u[x]+1,te[x]));
    }
    int c=0;
    for(int x=1;x<=n;x++)
    {
        if(!vis[x])
        {
        dfs(x);
        t.push_back(x);
        }
    }
    int z=t.size();
    int dia[z]={0};
    for(int x=0;x<z;x++)
        dia[x]=get(t[x]);
    int ans=0,ans1=0;
    /*for(int x=0;x<z;x++)
    cout<<t[x]<<" "<<dia[x]<<endl;*/
    for(int x=0;x<d.size();x++)
    ans=max(ans,d[x]);
    sort(dia,dia+z);
    if(z-2>=0)
    ans1=dia[z-1]+dia[z-2]+l;
    if(z-3>=0)
    ans1=max(ans1,dia[z-3]+dia[z-2]+2*l);
    return max(ans1,ans);
}    
/*int main()
{
    int ne,me,le;
    cin>>ne>>me>>le;
    int te[me],ae[me],be[me];
    for(int x=0;x<me;x++)
    cin>>ae[x]>>be[x]>>te[x];
    //for(int x=0;x<me;x++)
    //ae[x]++,be[x]++;
    cout<<travelTime(ne, me, le, ae , be , te );
}*/

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:97:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |     for(int x=0;x<d.size();x++)
      |                 ~^~~~~~~~~
dreaming.cpp:81:9: warning: unused variable 'c' [-Wunused-variable]
   81 |     int c=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 13060 KB Output is correct
2 Correct 36 ms 13124 KB Output is correct
3 Correct 30 ms 8696 KB Output is correct
4 Correct 7 ms 2132 KB Output is correct
5 Correct 5 ms 1364 KB Output is correct
6 Correct 10 ms 3056 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 19 ms 4856 KB Output is correct
9 Correct 24 ms 6640 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 35 ms 8764 KB Output is correct
12 Correct 40 ms 10824 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 13060 KB Output is correct
2 Correct 36 ms 13124 KB Output is correct
3 Correct 30 ms 8696 KB Output is correct
4 Correct 7 ms 2132 KB Output is correct
5 Correct 5 ms 1364 KB Output is correct
6 Correct 10 ms 3056 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 19 ms 4856 KB Output is correct
9 Correct 24 ms 6640 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 35 ms 8764 KB Output is correct
12 Correct 40 ms 10824 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 36 ms 13148 KB Output is correct
40 Correct 39 ms 13140 KB Output is correct
41 Correct 24 ms 8656 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 0 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 45 ms 9000 KB Output is correct
58 Correct 45 ms 8992 KB Output is correct
59 Correct 47 ms 8884 KB Output is correct
60 Correct 48 ms 8880 KB Output is correct
61 Correct 45 ms 8828 KB Output is correct
62 Correct 46 ms 8724 KB Output is correct
63 Correct 43 ms 8680 KB Output is correct
64 Correct 40 ms 8580 KB Output is correct
65 Correct 44 ms 8680 KB Output is correct
66 Correct 42 ms 8680 KB Output is correct
67 Correct 46 ms 8900 KB Output is correct
68 Correct 47 ms 8796 KB Output is correct
69 Correct 48 ms 8856 KB Output is correct
70 Correct 66 ms 8872 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 1 ms 468 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 1 ms 468 KB Output is correct
76 Correct 2 ms 468 KB Output is correct
77 Correct 2 ms 468 KB Output is correct
78 Correct 1 ms 468 KB Output is correct
79 Correct 1 ms 468 KB Output is correct
80 Correct 47 ms 8828 KB Output is correct
81 Correct 46 ms 8864 KB Output is correct
82 Correct 47 ms 8780 KB Output is correct
83 Correct 46 ms 8780 KB Output is correct
84 Correct 2 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 2 ms 468 KB Output is correct
88 Correct 1 ms 468 KB Output is correct
89 Correct 1 ms 468 KB Output is correct
90 Correct 1 ms 440 KB Output is correct
91 Correct 1 ms 468 KB Output is correct
92 Correct 1 ms 468 KB Output is correct
93 Correct 1 ms 468 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 0 ms 212 KB Output is correct
99 Correct 0 ms 212 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 224 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 5 ms 1364 KB Output is correct
105 Correct 9 ms 3040 KB Output is correct
106 Correct 1 ms 340 KB Output is correct
107 Correct 19 ms 4956 KB Output is correct
108 Correct 24 ms 6740 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 34 ms 8652 KB Output is correct
111 Correct 40 ms 10808 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 53 ms 14380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 6504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 5 ms 552 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 5 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 4 ms 468 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 2 ms 724 KB Output is correct
55 Correct 2 ms 724 KB Output is correct
56 Correct 8 ms 496 KB Output is correct
57 Correct 6 ms 468 KB Output is correct
58 Correct 2 ms 596 KB Output is correct
59 Correct 2 ms 576 KB Output is correct
60 Correct 8 ms 520 KB Output is correct
61 Correct 7 ms 468 KB Output is correct
62 Correct 2 ms 596 KB Output is correct
63 Correct 2 ms 596 KB Output is correct
64 Correct 4 ms 468 KB Output is correct
65 Correct 8 ms 468 KB Output is correct
66 Correct 2 ms 596 KB Output is correct
67 Correct 2 ms 596 KB Output is correct
68 Correct 8 ms 576 KB Output is correct
69 Correct 8 ms 496 KB Output is correct
70 Correct 8 ms 516 KB Output is correct
71 Correct 8 ms 468 KB Output is correct
72 Correct 1 ms 572 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 3 ms 576 KB Output is correct
75 Correct 3 ms 596 KB Output is correct
76 Correct 1 ms 596 KB Output is correct
77 Correct 2 ms 596 KB Output is correct
78 Correct 7 ms 516 KB Output is correct
79 Correct 7 ms 468 KB Output is correct
80 Correct 3 ms 340 KB Output is correct
81 Correct 2 ms 340 KB Output is correct
82 Correct 4 ms 596 KB Output is correct
83 Correct 4 ms 468 KB Output is correct
84 Correct 3 ms 452 KB Output is correct
85 Correct 2 ms 436 KB Output is correct
86 Correct 4 ms 468 KB Output is correct
87 Correct 2 ms 596 KB Output is correct
88 Correct 8 ms 516 KB Output is correct
89 Correct 8 ms 452 KB Output is correct
90 Correct 8 ms 468 KB Output is correct
91 Correct 8 ms 516 KB Output is correct
92 Correct 1 ms 476 KB Output is correct
93 Correct 1 ms 484 KB Output is correct
94 Correct 1 ms 468 KB Output is correct
95 Correct 1 ms 468 KB Output is correct
96 Correct 2 ms 468 KB Output is correct
97 Correct 1 ms 448 KB Output is correct
98 Correct 1 ms 468 KB Output is correct
99 Correct 2 ms 576 KB Output is correct
100 Correct 2 ms 468 KB Output is correct
101 Correct 1 ms 448 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 1 ms 212 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 0 ms 304 KB Output is correct
106 Correct 1 ms 212 KB Output is correct
107 Correct 0 ms 212 KB Output is correct
108 Correct 0 ms 212 KB Output is correct
109 Correct 1 ms 212 KB Output is correct
110 Correct 0 ms 212 KB Output is correct
111 Correct 0 ms 212 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 1 ms 340 KB Output is correct
114 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 13060 KB Output is correct
2 Correct 36 ms 13124 KB Output is correct
3 Correct 30 ms 8696 KB Output is correct
4 Correct 7 ms 2132 KB Output is correct
5 Correct 5 ms 1364 KB Output is correct
6 Correct 10 ms 3056 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 19 ms 4856 KB Output is correct
9 Correct 24 ms 6640 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 35 ms 8764 KB Output is correct
12 Correct 40 ms 10824 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 36 ms 13148 KB Output is correct
40 Correct 39 ms 13140 KB Output is correct
41 Correct 24 ms 8656 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 0 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 45 ms 9000 KB Output is correct
58 Correct 45 ms 8992 KB Output is correct
59 Correct 47 ms 8884 KB Output is correct
60 Correct 48 ms 8880 KB Output is correct
61 Correct 45 ms 8828 KB Output is correct
62 Correct 46 ms 8724 KB Output is correct
63 Correct 43 ms 8680 KB Output is correct
64 Correct 40 ms 8580 KB Output is correct
65 Correct 44 ms 8680 KB Output is correct
66 Correct 42 ms 8680 KB Output is correct
67 Correct 46 ms 8900 KB Output is correct
68 Correct 47 ms 8796 KB Output is correct
69 Correct 48 ms 8856 KB Output is correct
70 Correct 66 ms 8872 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 1 ms 468 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 1 ms 468 KB Output is correct
76 Correct 2 ms 468 KB Output is correct
77 Correct 2 ms 468 KB Output is correct
78 Correct 1 ms 468 KB Output is correct
79 Correct 1 ms 468 KB Output is correct
80 Correct 47 ms 8828 KB Output is correct
81 Correct 46 ms 8864 KB Output is correct
82 Correct 47 ms 8780 KB Output is correct
83 Correct 46 ms 8780 KB Output is correct
84 Correct 2 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 2 ms 468 KB Output is correct
88 Correct 1 ms 468 KB Output is correct
89 Correct 1 ms 468 KB Output is correct
90 Correct 1 ms 440 KB Output is correct
91 Correct 1 ms 468 KB Output is correct
92 Correct 1 ms 468 KB Output is correct
93 Correct 1 ms 468 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 0 ms 212 KB Output is correct
99 Correct 0 ms 212 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 224 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 5 ms 1364 KB Output is correct
105 Correct 9 ms 3040 KB Output is correct
106 Correct 1 ms 340 KB Output is correct
107 Correct 19 ms 4956 KB Output is correct
108 Correct 24 ms 6740 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 34 ms 8652 KB Output is correct
111 Correct 40 ms 10808 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 53 ms 14380 KB Output is correct
114 Execution timed out 1083 ms 6504 KB Time limit exceeded
115 Halted 0 ms 0 KB -