답안 #805681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805681 2023-08-03T20:15:01 Z Mouad_ouj 꿈 (IOI13_dreaming) C++17
47 / 100
1000 ms 14304 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=0,b=0,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(disb[a]);
    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;
    /*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);
    int ans1=dia[z-1]+dia[z-2]+l;
  	if(z-3>=0)
    ans1=max(ans1,dia[z-2]+dia[z-3]+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 35 ms 13140 KB Output is correct
2 Correct 34 ms 13132 KB Output is correct
3 Correct 23 ms 8648 KB Output is correct
4 Correct 5 ms 2132 KB Output is correct
5 Correct 4 ms 1364 KB Output is correct
6 Correct 9 ms 3128 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 18 ms 4972 KB Output is correct
9 Correct 24 ms 6740 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 8692 KB Output is correct
12 Correct 41 ms 10844 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 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 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 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 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 13140 KB Output is correct
2 Correct 34 ms 13132 KB Output is correct
3 Correct 23 ms 8648 KB Output is correct
4 Correct 5 ms 2132 KB Output is correct
5 Correct 4 ms 1364 KB Output is correct
6 Correct 9 ms 3128 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 18 ms 4972 KB Output is correct
9 Correct 24 ms 6740 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 8692 KB Output is correct
12 Correct 41 ms 10844 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 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 0 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 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 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 35 ms 13132 KB Output is correct
40 Correct 43 ms 13128 KB Output is correct
41 Correct 24 ms 8652 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 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 1 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 44 ms 8912 KB Output is correct
58 Correct 44 ms 8916 KB Output is correct
59 Correct 46 ms 8876 KB Output is correct
60 Correct 47 ms 8896 KB Output is correct
61 Correct 44 ms 8764 KB Output is correct
62 Correct 45 ms 8836 KB Output is correct
63 Correct 42 ms 8740 KB Output is correct
64 Correct 47 ms 8676 KB Output is correct
65 Correct 42 ms 8680 KB Output is correct
66 Correct 42 ms 8668 KB Output is correct
67 Correct 45 ms 8932 KB Output is correct
68 Correct 46 ms 8900 KB Output is correct
69 Correct 49 ms 8888 KB Output is correct
70 Correct 50 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 2 ms 468 KB Output is correct
75 Correct 1 ms 468 KB Output is correct
76 Correct 1 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 46 ms 8888 KB Output is correct
81 Correct 46 ms 8900 KB Output is correct
82 Correct 44 ms 8796 KB Output is correct
83 Correct 44 ms 8780 KB Output is correct
84 Correct 1 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 1 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 468 KB Output is correct
91 Correct 2 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 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 4 ms 1364 KB Output is correct
105 Correct 9 ms 3028 KB Output is correct
106 Correct 0 ms 340 KB Output is correct
107 Correct 19 ms 4960 KB Output is correct
108 Correct 29 ms 6644 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 34 ms 8704 KB Output is correct
111 Correct 44 ms 10912 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 55 ms 14304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 6456 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 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 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 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 1 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 6 ms 576 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 5 ms 596 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 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 1 ms 212 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 1 ms 304 KB Output is correct
42 Correct 1 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 1 ms 212 KB Output is correct
46 Correct 1 ms 308 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 0 ms 340 KB Output is correct
52 Incorrect 1 ms 212 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 13140 KB Output is correct
2 Correct 34 ms 13132 KB Output is correct
3 Correct 23 ms 8648 KB Output is correct
4 Correct 5 ms 2132 KB Output is correct
5 Correct 4 ms 1364 KB Output is correct
6 Correct 9 ms 3128 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 18 ms 4972 KB Output is correct
9 Correct 24 ms 6740 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 8692 KB Output is correct
12 Correct 41 ms 10844 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 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 0 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 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 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 35 ms 13132 KB Output is correct
40 Correct 43 ms 13128 KB Output is correct
41 Correct 24 ms 8652 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 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 1 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 44 ms 8912 KB Output is correct
58 Correct 44 ms 8916 KB Output is correct
59 Correct 46 ms 8876 KB Output is correct
60 Correct 47 ms 8896 KB Output is correct
61 Correct 44 ms 8764 KB Output is correct
62 Correct 45 ms 8836 KB Output is correct
63 Correct 42 ms 8740 KB Output is correct
64 Correct 47 ms 8676 KB Output is correct
65 Correct 42 ms 8680 KB Output is correct
66 Correct 42 ms 8668 KB Output is correct
67 Correct 45 ms 8932 KB Output is correct
68 Correct 46 ms 8900 KB Output is correct
69 Correct 49 ms 8888 KB Output is correct
70 Correct 50 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 2 ms 468 KB Output is correct
75 Correct 1 ms 468 KB Output is correct
76 Correct 1 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 46 ms 8888 KB Output is correct
81 Correct 46 ms 8900 KB Output is correct
82 Correct 44 ms 8796 KB Output is correct
83 Correct 44 ms 8780 KB Output is correct
84 Correct 1 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 1 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 468 KB Output is correct
91 Correct 2 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 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 4 ms 1364 KB Output is correct
105 Correct 9 ms 3028 KB Output is correct
106 Correct 0 ms 340 KB Output is correct
107 Correct 19 ms 4960 KB Output is correct
108 Correct 29 ms 6644 KB Output is correct
109 Correct 1 ms 340 KB Output is correct
110 Correct 34 ms 8704 KB Output is correct
111 Correct 44 ms 10912 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 55 ms 14304 KB Output is correct
114 Execution timed out 1081 ms 6456 KB Time limit exceeded
115 Halted 0 ms 0 KB -