Submission #1102640

# Submission time Handle Problem Language Result Execution time Memory
1102640 2024-10-18T14:27:54 Z asli_bg Crocodile's Underground City (IOI11_crocodile) C++11
46 / 100
229 ms 262144 KB
#pragma GCC optimize("O3,unroll-loops")
#include "crocodile.h"
 
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vii;
 
#define cont(x) for(auto el:x) {cout<<el<<' ';} cout<<endl;
#define endl '\n'
#define contp(x) for(auto el:x) {cout<<el.fi<<'-'<<el.se<<' ';} cout<<endl;
#define pb push_back
 
#define sp <<' '<<
 
#define DEBUG(x) {cout<<(#x) sp x<<endl;}
 
const int MAXN=1e5+5;
const int INF=1e9;
 
int n,m,k;
vii adj[MAXN];
int mn[MAXN],mn2[MAXN];
bool cikis[MAXN];

void dfs(int nd,int ata){
    for(auto el:adj[nd]){
        int kom=el.fi;
        int cost=el.se;
        if(kom==ata) continue;
        dfs(kom,nd);
        //mn[nd], mn2[nd] / mn[kom], mn2[kom]
        vi temp;
        temp.pb(mn[nd]);
        temp.pb(mn2[nd]);
        temp.pb(mn2[kom]+cost);
        sort(all(temp));

        mn[nd]=temp[0];
        mn2[nd]=temp[1];
    }
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n=N;
    m=M;
    k=K;
    FOR(i,m){
        int bir=R[i][0];
        int iki=R[i][1];
        bir++;iki++;
        adj[bir].pb({iki,L[i]});
        adj[iki].pb({bir,L[i]});
    }
 
    FOR(i,k){
        P[i]++;
        cikis[P[i]]=true;
    }

    FORE(i,1,n+1){
        if(cikis[i]) {mn[i]=mn2[i]=0;}
        else mn[i]=mn2[i]=INF;
    }

    dfs(1,0);

    return mn2[1];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 2 ms 6484 KB Output is correct
3 Correct 2 ms 6636 KB Output is correct
4 Correct 2 ms 6484 KB Output is correct
5 Correct 3 ms 6652 KB Output is correct
6 Correct 2 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 2 ms 6484 KB Output is correct
3 Correct 2 ms 6636 KB Output is correct
4 Correct 2 ms 6484 KB Output is correct
5 Correct 3 ms 6652 KB Output is correct
6 Correct 2 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6740 KB Output is correct
9 Runtime error 229 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 2 ms 6484 KB Output is correct
3 Correct 2 ms 6636 KB Output is correct
4 Correct 2 ms 6484 KB Output is correct
5 Correct 3 ms 6652 KB Output is correct
6 Correct 2 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6740 KB Output is correct
9 Runtime error 229 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -