답안 #805699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805699 2023-08-03T20:50:58 Z Mouad_ouj 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 17504 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int> >> adj;
vector<bool> vis;
vector<vector<int> > t;
vector<int> d,ty;
int n,m,l;
void dfs(int node,int f)
{
    vis[node]=true;
    int k=adj[node].size();
    for(int x=0;x<k;x++)
    {
        int to=adj[node][x].first;
        if(!vis[to])
        {
        t[f].push_back(to);    
        dfs(to,f);
        }
    }
}
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 cn=t[y].size();
    int dis[n+1]={0},disa[n+1]={0},disb[n+1]={0},a=0,b=0,cur=0;
    vis.assign(n+1,false);
    if(adj[y].size()!=0)
    dfs3(y,dis);
    else 
    return 0;
    for(int x=0;x<cn;x++)
    {
        if(cur<=dis[t[y][x]] && t[y][x]!=y)
        {
            a=t[y][x];
            cur=dis[t[y][x]];
        }
    }    
    vis.assign(n+1,false);
    dfs3(a,disa);
    cur=0;
    for(int x=0;x<cn;x++)
    {
        if(cur<disa[t[y][x]] && t[y][x]!=a)
        {
            b=t[y][x];
            cur=disa[t[y][x]];
        }
    }
    vis.assign(n+1,false);
    dfs3(b,disb);
    int ans=disb[a];
    for(int x=0;x<cn;x++)
        ans=min(ans,max(disa[t[y][x]],disb[t[y][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);
    t.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])
        {
        t[x].push_back(x);    
        dfs(x,x);
        ty.push_back(x);
        }
    }
    int z=ty.size();
    int dia[z]={0};
    for(int x=0;x<z;x++)
        dia[x]=get(ty[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:101:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |     for(int x=0;x<d.size();x++)
      |                 ~^~~~~~~~~
dreaming.cpp:84:9: warning: unused variable 'c' [-Wunused-variable]
   84 |     int c=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 15692 KB Output is correct
2 Correct 53 ms 15648 KB Output is correct
3 Correct 37 ms 10412 KB Output is correct
4 Correct 5 ms 2516 KB Output is correct
5 Correct 5 ms 1620 KB Output is correct
6 Correct 10 ms 3696 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 19 ms 6228 KB Output is correct
9 Correct 25 ms 8172 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 10768 KB Output is correct
12 Correct 42 ms 13112 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 1 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 0 ms 212 KB Output is correct
15 Correct 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 15692 KB Output is correct
2 Correct 53 ms 15648 KB Output is correct
3 Correct 37 ms 10412 KB Output is correct
4 Correct 5 ms 2516 KB Output is correct
5 Correct 5 ms 1620 KB Output is correct
6 Correct 10 ms 3696 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 19 ms 6228 KB Output is correct
9 Correct 25 ms 8172 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 10768 KB Output is correct
12 Correct 42 ms 13112 KB Output is correct
13 Correct 1 ms 340 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 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 1 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 0 ms 212 KB Output is correct
28 Correct 1 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 1 ms 212 KB Output is correct
39 Correct 38 ms 15680 KB Output is correct
40 Correct 43 ms 15660 KB Output is correct
41 Correct 27 ms 10472 KB Output is correct
42 Correct 6 ms 2536 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 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 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 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 65 ms 11888 KB Output is correct
58 Correct 47 ms 11848 KB Output is correct
59 Correct 49 ms 11712 KB Output is correct
60 Correct 48 ms 11736 KB Output is correct
61 Correct 47 ms 11644 KB Output is correct
62 Correct 48 ms 11712 KB Output is correct
63 Correct 43 ms 11472 KB Output is correct
64 Correct 43 ms 11500 KB Output is correct
65 Correct 46 ms 11508 KB Output is correct
66 Correct 55 ms 11472 KB Output is correct
67 Correct 50 ms 11696 KB Output is correct
68 Correct 47 ms 11728 KB Output is correct
69 Correct 51 ms 11724 KB Output is correct
70 Correct 52 ms 11712 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 2 ms 596 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 2 ms 596 KB Output is correct
75 Correct 2 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 2 ms 596 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 47 ms 11756 KB Output is correct
81 Correct 51 ms 11756 KB Output is correct
82 Correct 46 ms 11540 KB Output is correct
83 Correct 45 ms 11648 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 2 ms 596 KB Output is correct
87 Correct 1 ms 596 KB Output is correct
88 Correct 1 ms 596 KB Output is correct
89 Correct 1 ms 596 KB Output is correct
90 Correct 1 ms 596 KB Output is correct
91 Correct 2 ms 596 KB Output is correct
92 Correct 2 ms 596 KB Output is correct
93 Correct 1 ms 596 KB Output is correct
94 Correct 0 ms 224 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 0 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 0 ms 212 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 5 ms 1748 KB Output is correct
105 Correct 10 ms 3796 KB Output is correct
106 Correct 1 ms 340 KB Output is correct
107 Correct 19 ms 6228 KB Output is correct
108 Correct 25 ms 8116 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 36 ms 10748 KB Output is correct
111 Correct 41 ms 13104 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 57 ms 17504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 10916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 1 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 0 ms 212 KB Output is correct
15 Correct 1 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 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 596 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 1 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 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 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 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 2 ms 724 KB Output is correct
55 Correct 1 ms 724 KB Output is correct
56 Correct 2 ms 528 KB Output is correct
57 Correct 2 ms 572 KB Output is correct
58 Correct 1 ms 596 KB Output is correct
59 Correct 1 ms 596 KB Output is correct
60 Correct 2 ms 596 KB Output is correct
61 Correct 2 ms 596 KB Output is correct
62 Correct 2 ms 596 KB Output is correct
63 Correct 1 ms 596 KB Output is correct
64 Correct 3 ms 596 KB Output is correct
65 Correct 2 ms 596 KB Output is correct
66 Correct 2 ms 596 KB Output is correct
67 Correct 1 ms 596 KB Output is correct
68 Correct 2 ms 596 KB Output is correct
69 Correct 2 ms 596 KB Output is correct
70 Correct 3 ms 576 KB Output is correct
71 Correct 2 ms 596 KB Output is correct
72 Correct 1 ms 596 KB Output is correct
73 Correct 1 ms 596 KB Output is correct
74 Correct 2 ms 596 KB Output is correct
75 Correct 2 ms 596 KB Output is correct
76 Correct 1 ms 596 KB Output is correct
77 Correct 1 ms 596 KB Output is correct
78 Correct 2 ms 596 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 2 ms 596 KB Output is correct
81 Correct 2 ms 596 KB Output is correct
82 Correct 2 ms 596 KB Output is correct
83 Correct 2 ms 596 KB Output is correct
84 Correct 2 ms 596 KB Output is correct
85 Correct 3 ms 596 KB Output is correct
86 Correct 2 ms 592 KB Output is correct
87 Correct 2 ms 596 KB Output is correct
88 Correct 3 ms 596 KB Output is correct
89 Correct 2 ms 596 KB Output is correct
90 Correct 2 ms 596 KB Output is correct
91 Correct 2 ms 596 KB Output is correct
92 Correct 1 ms 596 KB Output is correct
93 Correct 1 ms 468 KB Output is correct
94 Correct 1 ms 596 KB Output is correct
95 Correct 1 ms 596 KB Output is correct
96 Correct 1 ms 596 KB Output is correct
97 Correct 1 ms 596 KB Output is correct
98 Correct 1 ms 596 KB Output is correct
99 Correct 2 ms 596 KB Output is correct
100 Correct 1 ms 596 KB Output is correct
101 Correct 1 ms 596 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 0 ms 212 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 0 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 52 ms 15692 KB Output is correct
2 Correct 53 ms 15648 KB Output is correct
3 Correct 37 ms 10412 KB Output is correct
4 Correct 5 ms 2516 KB Output is correct
5 Correct 5 ms 1620 KB Output is correct
6 Correct 10 ms 3696 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 19 ms 6228 KB Output is correct
9 Correct 25 ms 8172 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 45 ms 10768 KB Output is correct
12 Correct 42 ms 13112 KB Output is correct
13 Correct 1 ms 340 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 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 1 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 0 ms 212 KB Output is correct
28 Correct 1 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 1 ms 212 KB Output is correct
39 Correct 38 ms 15680 KB Output is correct
40 Correct 43 ms 15660 KB Output is correct
41 Correct 27 ms 10472 KB Output is correct
42 Correct 6 ms 2536 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 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 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 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 65 ms 11888 KB Output is correct
58 Correct 47 ms 11848 KB Output is correct
59 Correct 49 ms 11712 KB Output is correct
60 Correct 48 ms 11736 KB Output is correct
61 Correct 47 ms 11644 KB Output is correct
62 Correct 48 ms 11712 KB Output is correct
63 Correct 43 ms 11472 KB Output is correct
64 Correct 43 ms 11500 KB Output is correct
65 Correct 46 ms 11508 KB Output is correct
66 Correct 55 ms 11472 KB Output is correct
67 Correct 50 ms 11696 KB Output is correct
68 Correct 47 ms 11728 KB Output is correct
69 Correct 51 ms 11724 KB Output is correct
70 Correct 52 ms 11712 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 2 ms 596 KB Output is correct
73 Correct 2 ms 596 KB Output is correct
74 Correct 2 ms 596 KB Output is correct
75 Correct 2 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 2 ms 596 KB Output is correct
79 Correct 2 ms 596 KB Output is correct
80 Correct 47 ms 11756 KB Output is correct
81 Correct 51 ms 11756 KB Output is correct
82 Correct 46 ms 11540 KB Output is correct
83 Correct 45 ms 11648 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 2 ms 596 KB Output is correct
87 Correct 1 ms 596 KB Output is correct
88 Correct 1 ms 596 KB Output is correct
89 Correct 1 ms 596 KB Output is correct
90 Correct 1 ms 596 KB Output is correct
91 Correct 2 ms 596 KB Output is correct
92 Correct 2 ms 596 KB Output is correct
93 Correct 1 ms 596 KB Output is correct
94 Correct 0 ms 224 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 0 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 0 ms 212 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 5 ms 1748 KB Output is correct
105 Correct 10 ms 3796 KB Output is correct
106 Correct 1 ms 340 KB Output is correct
107 Correct 19 ms 6228 KB Output is correct
108 Correct 25 ms 8116 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 36 ms 10748 KB Output is correct
111 Correct 41 ms 13104 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 57 ms 17504 KB Output is correct
114 Execution timed out 1077 ms 10916 KB Time limit exceeded
115 Halted 0 ms 0 KB -