Submission #962978

# Submission time Handle Problem Language Result Execution time Memory
962978 2024-04-14T10:24:52 Z vivkostov Dreaming (IOI13_dreaming) C++14
0 / 100
37 ms 13652 KB
#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
struct cell
{
    int to,cost;
};
int n,m,l,A[100005],B[100005],C[100005],used[100005],sum[100005],le[10],otg[100005];
vector<cell>v[100005];
void find_sum(int beg,int lead,int num)
{
    used[beg]=1;
    int w;
    if(v[beg].size()==1)le[num]=beg;
    for(int i=0;i<(int)(v[beg].size());i++)
    {
        w=v[beg][i].to;
        if(!used[w])
        {
            find_sum(w,lead,num);
            sum[num]+=v[beg][i].cost;
        }
    }
}
void find_mid(int beg,int izm,int num)
{
    used[beg]=1;
    int w;
    otg[num]=min(otg[num],max(izm,sum[num]-izm));
    for(int i=0;i<(int)(v[beg].size());i++)
    {
        w=v[beg][i].to;
        if(!used[w])
        {
            find_mid(w,izm+v[beg][i].cost,num);
        }
    }
}
int travelTime(int n,int m,int l,int A[],int B[],int C[])
//void read()
{
    //cin>>n>>m>>l;
    cell h;
    for(int i=1;i<=m;i++)
    {
        //cin>>A[i]>>B[i]>>C[i];
        A[i]++;
        B[i]++;
        h.to=A[i];
        h.cost=C[i];
        v[B[i]].push_back(h);
        h.to=B[i];
        v[A[i]].push_back(h);
    }
    int br=0;
    for(int i=1;i<=n;i++)
    {
        if(!used[i])
        {
            br++;
            find_sum(i,i,br);
        }
    }
    memset(used,0,sizeof(used));
    otg[1]=sum[1];
    otg[2]=sum[2];
    find_mid(le[1],0,1);
    find_mid(le[2],0,2);
    int aa=0;
    for(int i=1;i<=n;i++)
    {
        aa=max(aa,sum[i]);
    }
    aa=max(aa,l+otg[1]+otg[2]);
    //cout<<aa<<endl;
    return aa;
}
/*int main()
{
    speed();
    read();
    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 37 ms 13652 KB Output is correct
2 Correct 33 ms 13412 KB Output is correct
3 Correct 22 ms 10588 KB Output is correct
4 Correct 6 ms 6120 KB Output is correct
5 Correct 4 ms 5468 KB Output is correct
6 Incorrect 9 ms 6624 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 13652 KB Output is correct
2 Correct 33 ms 13412 KB Output is correct
3 Correct 22 ms 10588 KB Output is correct
4 Correct 6 ms 6120 KB Output is correct
5 Correct 4 ms 5468 KB Output is correct
6 Incorrect 9 ms 6624 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 6980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 13652 KB Output is correct
2 Correct 33 ms 13412 KB Output is correct
3 Correct 22 ms 10588 KB Output is correct
4 Correct 6 ms 6120 KB Output is correct
5 Correct 4 ms 5468 KB Output is correct
6 Incorrect 9 ms 6624 KB Output isn't correct
7 Halted 0 ms 0 KB -