# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
320436 | 2020-11-08T18:49:58 Z | wildturtle | 꿈 (IOI13_dreaming) | C++14 | 76 ms | 22244 KB |
#include "dreaming.h" #include<bits/stdc++.h> using namespace std; int a,b,c,d,i,e,f,g,n,m,k,l,fix[500005],maxx,idx,maxx1; vector < pair <int,int> > v[500005]; vector <int> v1; stack <int> ms; void dfs(int x,int y,int z) { fix[x]=1; if(maxx<z) { maxx=z; idx=x; } for(int i=0;i<v[x].size();i++) { if(v[x][i].first==y) continue; dfs(v[x][i].first,x,z+v[x][i].second); } } void dfs1(int x,int y,int z,int p) { if(z!=-1 && k==0) ms.push(v[z][p].second); for(int i=0;i<v[x].size();i++) { if(v[x][i].first==z) continue; dfs1(v[x][i].first,y,x,i); } if(x==y) k=1; if(k==0) ms.pop(); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for(int i=0;i<M;i++) { v[A[i]].push_back( { B[i] , T[i] } ); v[B[i]].push_back( { A[i] , T[i] } ); } for(int i=0;i<N;i++) { if(fix[i]) continue; //cout<<i<<" "; maxx=0; idx=-1; dfs(i,-1,0); a=idx; maxx=0; idx=-1; dfs(a,-1,0); b=idx; maxx1=max(maxx1,maxx); k=0; dfs1(a,b,-1,0); //cout<<a<<" "<<b<<" "<<maxx<<" "; if(ms.empty()) v1.push_back(0); a=0; while(!ms.empty()) { //cout<<ms.top()<<"-"; a+=ms.top(); if(a==maxx/2) { v1.push_back(maxx/2); break; } else if(a>maxx/2) { v1.push_back(min(a,max(a-ms.top(),maxx-a+ms.top()))); break; } ms.pop(); } while(!ms.empty()) ms.pop(); //cout<<v1[v1.size()-1]<<endl; } sort(v1.begin(),v1.end()); if(v1.size()>=2) maxx1=max(maxx1,v1[v1.size()-1]+v1[v1.size()-2]+L); if(v1.size()>=3) maxx1=max(maxx1,v1[v1.size()-2]+v1[v1.size()-3]+2*L); return maxx1; }/* int main() { int a1[]={0,8,2,5,5,1,1,10}; int b1[]={8,2,7,11,1,3,9,6}; int c1[]={4,2,4,3,7,1,5,3}; cout<<travelTime(12, 8, 2, a1, b1, c1); }*/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 20964 KB | Output is correct |
2 | Correct | 58 ms | 22244 KB | Output is correct |
3 | Correct | 43 ms | 18916 KB | Output is correct |
4 | Correct | 15 ms | 13548 KB | Output is correct |
5 | Correct | 13 ms | 12908 KB | Output is correct |
6 | Correct | 20 ms | 14316 KB | Output is correct |
7 | Correct | 8 ms | 12160 KB | Output is correct |
8 | Correct | 33 ms | 15716 KB | Output is correct |
9 | Correct | 40 ms | 17124 KB | Output is correct |
10 | Correct | 8 ms | 12140 KB | Output is correct |
11 | Correct | 60 ms | 18916 KB | Output is correct |
12 | Correct | 76 ms | 20708 KB | Output is correct |
13 | Incorrect | 8 ms | 12140 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 20964 KB | Output is correct |
2 | Correct | 58 ms | 22244 KB | Output is correct |
3 | Correct | 43 ms | 18916 KB | Output is correct |
4 | Correct | 15 ms | 13548 KB | Output is correct |
5 | Correct | 13 ms | 12908 KB | Output is correct |
6 | Correct | 20 ms | 14316 KB | Output is correct |
7 | Correct | 8 ms | 12160 KB | Output is correct |
8 | Correct | 33 ms | 15716 KB | Output is correct |
9 | Correct | 40 ms | 17124 KB | Output is correct |
10 | Correct | 8 ms | 12140 KB | Output is correct |
11 | Correct | 60 ms | 18916 KB | Output is correct |
12 | Correct | 76 ms | 20708 KB | Output is correct |
13 | Incorrect | 8 ms | 12140 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 20964 KB | Output is correct |
2 | Correct | 58 ms | 22244 KB | Output is correct |
3 | Correct | 43 ms | 18916 KB | Output is correct |
4 | Correct | 15 ms | 13548 KB | Output is correct |
5 | Correct | 13 ms | 12908 KB | Output is correct |
6 | Correct | 20 ms | 14316 KB | Output is correct |
7 | Correct | 8 ms | 12160 KB | Output is correct |
8 | Correct | 33 ms | 15716 KB | Output is correct |
9 | Correct | 40 ms | 17124 KB | Output is correct |
10 | Correct | 8 ms | 12140 KB | Output is correct |
11 | Correct | 60 ms | 18916 KB | Output is correct |
12 | Correct | 76 ms | 20708 KB | Output is correct |
13 | Incorrect | 8 ms | 12140 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 15212 KB | Output is correct |
2 | Correct | 30 ms | 15588 KB | Output is correct |
3 | Correct | 31 ms | 15588 KB | Output is correct |
4 | Correct | 32 ms | 15592 KB | Output is correct |
5 | Correct | 34 ms | 15716 KB | Output is correct |
6 | Correct | 32 ms | 16108 KB | Output is correct |
7 | Correct | 35 ms | 15720 KB | Output is correct |
8 | Correct | 29 ms | 15588 KB | Output is correct |
9 | Correct | 30 ms | 15460 KB | Output is correct |
10 | Correct | 31 ms | 15716 KB | Output is correct |
11 | Correct | 8 ms | 12140 KB | Output is correct |
12 | Correct | 12 ms | 13160 KB | Output is correct |
13 | Correct | 12 ms | 13160 KB | Output is correct |
14 | Correct | 12 ms | 13160 KB | Output is correct |
15 | Correct | 12 ms | 13160 KB | Output is correct |
16 | Correct | 12 ms | 13160 KB | Output is correct |
17 | Correct | 14 ms | 13160 KB | Output is correct |
18 | Correct | 12 ms | 13160 KB | Output is correct |
19 | Correct | 12 ms | 13160 KB | Output is correct |
20 | Correct | 8 ms | 12140 KB | Output is correct |
21 | Correct | 8 ms | 12140 KB | Output is correct |
22 | Correct | 8 ms | 12140 KB | Output is correct |
23 | Correct | 12 ms | 13160 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 20964 KB | Output is correct |
2 | Correct | 58 ms | 22244 KB | Output is correct |
3 | Correct | 43 ms | 18916 KB | Output is correct |
4 | Correct | 15 ms | 13548 KB | Output is correct |
5 | Correct | 13 ms | 12908 KB | Output is correct |
6 | Correct | 20 ms | 14316 KB | Output is correct |
7 | Correct | 8 ms | 12160 KB | Output is correct |
8 | Correct | 33 ms | 15716 KB | Output is correct |
9 | Correct | 40 ms | 17124 KB | Output is correct |
10 | Correct | 8 ms | 12140 KB | Output is correct |
11 | Correct | 60 ms | 18916 KB | Output is correct |
12 | Correct | 76 ms | 20708 KB | Output is correct |
13 | Incorrect | 8 ms | 12140 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 20964 KB | Output is correct |
2 | Correct | 58 ms | 22244 KB | Output is correct |
3 | Correct | 43 ms | 18916 KB | Output is correct |
4 | Correct | 15 ms | 13548 KB | Output is correct |
5 | Correct | 13 ms | 12908 KB | Output is correct |
6 | Correct | 20 ms | 14316 KB | Output is correct |
7 | Correct | 8 ms | 12160 KB | Output is correct |
8 | Correct | 33 ms | 15716 KB | Output is correct |
9 | Correct | 40 ms | 17124 KB | Output is correct |
10 | Correct | 8 ms | 12140 KB | Output is correct |
11 | Correct | 60 ms | 18916 KB | Output is correct |
12 | Correct | 76 ms | 20708 KB | Output is correct |
13 | Incorrect | 8 ms | 12140 KB | Output isn't correct |