답안 #234743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234743 2020-05-25T12:44:07 Z muhammad_hokimiyon 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
8 ms 3072 KB
#include "crocodile.h"
#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 2e6 + 7;
const int N = 1e5 + 7;
const int M = 22;
const int mod = 998244353;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int b[N];
bool used[N];
vector < pair < int , ll > > v[N];

ll dfs( int x )
{
    if( used[x] )return 0;
    if( b[x] ){
        return 0;
    }
    used[x] = true;
    vector < ll > g;
    for( int i = 0; i < (int)v[x].size(); i++ ){
        auto y = v[x][i];
        if( used[y.fi] )continue;
        ll xx = dfs( y.fi ) + y.se;
        //cout << x << " " << y.fi << " " << xx << "\n";
        g.push_back(xx);
    }
    if( (int)g.size() < 2 )return g[0];
    sort( g.begin() , g.end() );
    return g[1];
}

int travel_plan(int n, int m, int a[][2], int l[], int k, int p[])
{
    for( int i = 0; i < m; i++ ){
        a[i][0] += 1 , a[i][1] += 1;
    }
    for( int i = 0; i < m; i++ ){
        v[a[i][0]].push_back({ a[i][1] , l[i] });
        v[a[i][1]].push_back({ a[i][0] , l[i] });
    }
    for( int i = 0; i < k; i++ ){
        p[i] += 1;
        b[p[i]] = 1;
    }
    return dfs(1);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2944 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2944 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Incorrect 8 ms 3072 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 7 ms 2944 KB Output is correct
5 Correct 7 ms 2816 KB Output is correct
6 Correct 6 ms 2816 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Incorrect 8 ms 3072 KB Output isn't correct
10 Halted 0 ms 0 KB -