# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
29663 |
2017-07-20T10:07:52 Z |
inqr |
Dreaming (IOI13_dreaming) |
C++14 |
|
1000 ms |
24056 KB |
#include "dreaming.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define DB printf("debug\n");
using namespace std;
int n,m,l;
vector < pair < int , int > > ed[100005];
vector < bool > dfsv(100005,0);
int enuzakyol,enuzaknod;
void dfsmax(int vn,int wn,int rn1,int rn2){
if(dfsv[vn])return;
dfsv[vn]=1;
//printf("dfsmax %d %d %d %d\n",vn,wn,rn1,rn2);
if(wn>enuzakyol){
enuzakyol=wn;
enuzaknod=vn;
}
for(int i=0;i<ed[vn].size();i++){
if(dfsv[ed[vn][i].st]==0)
dfsmax(ed[vn][i].st,wn+ed[vn][i].nd,rn1,rn2);
}
if(rn1==vn and dfsv[rn2]==0)dfsmax(rn2,wn+l,rn1,rn2);
else if(rn2==vn and dfsv[rn1]==0)dfsmax(rn1,wn+l,rn1,rn2);
}
int enuzak(int rn1,int rn2){
enuzakyol=-1,enuzaknod=-1;
fill(dfsv.begin(),dfsv.end(),0);
if(ed[0].size())dfsmax(0,0,rn1,rn2);
else dfsmax(1,0,rn1,rn2);
//printf("enuzakyol=%d enuzaknod=%d\n",enuzakyol,enuzaknod);
enuzakyol=-1;
fill(dfsv.begin(),dfsv.end(),0);
dfsmax(enuzaknod,0,rn1,rn2);
return enuzakyol;
}
int solve(int teknod){
int enuzakyolyeni=INT_MAX;
//printf("teknod=%d\n",teknod);
for(int i=0;i<n;i++){
if(i!=teknod){
//printf("enuzak %d %d\n",i,teknod);
enuzakyolyeni=min(enuzakyolyeni,enuzak(i,teknod));
}
}
return enuzakyolyeni;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
n=N,m=M,l=L;
for(int i=0;i<M;i++){
ed[A[i]].pb(mp(B[i],T[i]));
ed[B[i]].pb(mp(A[i],T[i]));
}
int teknod=-1;
for(int i=0;i<N;i++){
if(ed[i].size()==0){
//printf("i=%d i.size=%d\n",i,(int)ed[i].size());
teknod=i;
}
}
return solve(teknod);
}
Compilation message
dreaming.cpp: In function 'void dfsmax(int, int, int, int)':
dreaming.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<ed[vn].size();i++){
~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
24056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
24056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
24056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1056 ms |
4984 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
24056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
24056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |