답안 #622621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
622621 2022-08-04T12:35:09 Z BhavayGoyal 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
5 ms 1748 KB
#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define endl "\n"

const int N = 1005;
vector<array<int, 2>> g[N];
vi temp[N];
int dis[N], vis[N];

void dfs(int src) {
    vis[src] = true;
    for (auto ch : g[src]) {
        int child = ch[0], wt = ch[1];
        if (!vis[child]) {
            dfs(child);
            temp[src].pb(dis[child]+wt);
            dis[src] = min(dis[src], dis[child] + wt);
        }
    }
    if (g[src].size() == 1) dis[src] = 0;
    else {
        sort (all(temp[src]));
        dis[src] = temp[src][1];
    }
}

int travel_plan(int n, int m, int (*r)[2], int* l, int k, int *p) {
    memset(dis, 63, sizeof dis);
    vii edges; 
    vi entry;
    for (int i = 0; i < m; i++) edges.pb({r[i][0], r[i][1]});
    for (int i = 0; i < m; i++) edges[i].pb(l[i]);
    for (int i = 0; i < k; i++) {
        int x = p[i];
        entry.pb(x);
    }

    for (auto i : edges) {
        int a = i[0], b = i[1], c = i[2];
        g[a].pb({b, c});
        g[b].pb({a, c});
    }
    dfs(0);
    return dis[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Runtime error 5 ms 1748 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Runtime error 5 ms 1748 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -