Submission #962243

# Submission time Handle Problem Language Result Execution time Memory
962243 2024-04-13T09:39:17 Z vivkostov Dreaming (IOI13_dreaming) C++14
0 / 100
38 ms 13184 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,a1[100005],a2[100005],a3[100005],used[100005],ma[100005],sma[100005],a,in[100005],otg[100005],costin[100005];
vector<cell>v[100005];
void dfs(int beg)
{
    used[beg]=1;
    int w;
    for(int i=0;i<v[beg].size();i++)
    {
        w=v[beg][i].to;
        if(!used[w])
        {
            dfs(w);
            if(ma[beg]<ma[w]+v[beg][i].cost)
            {
                in[beg]=w;
                costin[beg]=v[beg][i].cost;
                sma[beg]=ma[beg];
                ma[beg]=ma[w]+v[beg][i].cost;
            }
            else if(sma[beg]<ma[w]+v[beg][i].cost)
            {
                sma[beg]=ma[w]+v[beg][i].cost;
            }
        }
    }
}
void find_ma(int beg,int izm,int par)
{
    if(beg==par)return;
    if(izm>ma[beg])
    {
        int g=izm;
        g=min(izm,ma[par]);
        otg[beg]=g;
        return;
    }
    find_ma(in[beg],max(izm,sma[beg])+costin[beg],beg);
}
void fil(int beg)
{
    int w;
    used[beg]=1;
    for(int i=0;i<v[beg].size();i++)
    {
        w=v[beg][i].to;
        if(!used[w])
        {
            fil(w);
        }
    }
}
int travelTime(int n,int m,int l,int a1[],int a2[],int a3[])
{
    cell h;
    for(int i=1;i<=m;i++)
    {
        h.to=a2[i];
        h.cost=a3[i];
        v[a1[i]].push_back(h);
        h.to=a1[i];
        v[a2[i]].push_back(h);
    }
    for(int i=1;i<=n;i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }
    memset(used,0,sizeof(used));
    for(int i=1;i<=n;i++)
    {
        if(!used[i])
        {
            find_ma(i,0,0);
            fil(i);
        }
    }
    sort(otg+1,otg+n+1);
    return otg[n-1]+otg[n]+l;
}

Compilation message

dreaming.cpp: In function 'void dfs(int)':
dreaming.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
dreaming.cpp: In function 'void fil(int)':
dreaming.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i=0;i<v[beg].size();i++)
      |                 ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 13184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 13184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8028 KB Output is correct
2 Incorrect 15 ms 8148 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 13184 KB Output isn't correct
2 Halted 0 ms 0 KB -