Submission #136542

# Submission time Handle Problem Language Result Execution time Memory
136542 2019-07-25T13:01:13 Z miguel Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
255 ms 262148 KB
#include<bits/stdc++.h>
#include<crocodile.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
vector <pi> g[10001];
int t[10001];

void dfs(int nod, int p){
    for(pi i: g[nod]){
        if(i.x!=p) dfs(i.x, nod);
    }
    int mn[2];
    mn[0]=mn[1]=1000000001;
    if(t[nod]==1000000001){
        for(pi i: g[nod]){
            if(i.x!=p){
                int xd=t[i.x]+i.y;
                for(int id=0; id<2; id++) if(mn[id]>xd) swap(xd, mn[id]);
            }
        }
        t[nod]=mn[1];
    }
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    for(int i=0; i<n; i++) t[i]=1000000001;
    for(int i=0; i<k; i++) t[p[i]]=0;
    for(int i=0; i<m; i++){
        g[r[i][0]].pb({r[i][1], l[i]});
        g[r[i][1]].pb({r[i][0], l[i]});
    }
    dfs(0, -1);
    return t[0];
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Runtime error 255 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Runtime error 255 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -