답안 #878276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878276 2023-11-24T07:55:12 Z boris_mihov 자매 도시 (APIO20_swap) C++17
0 / 100
2000 ms 15036 KB
#include "swap.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
 
typedef long long llong;
const int MAXN = 100000 + 10;
const int INF  = 1e9;
 
int n, m;
bool vis[MAXN];
std::vector <std::pair <int,int>> g[MAXN];
 
int dfs(int node, int par, int dist)
{
    int res = 2;
    vis[node] = true;
    for (const auto &[u, d] : g[node])
    {
        if (d > dist) 
        {
            continue;
        }

        res--;
        if (vis[u])
        {
            continue;
        }
 
        res += dfs(u, node, dist);
    }
    
    return res;
}
 
bool check(int u, int v, int dist)
{
    std::fill(vis + 1, vis + 1 + n, false);
    bool cycle = (dfs(u, 0, dist) <= 0);
    return cycle && vis[v];
}
 
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) 
{
    n = N; m = M;
    for (int i = 0 ; i < M ; ++i)
    {
        U[i]++; V[i]++;
        g[U[i]].emplace_back(V[i], W[i]);
        g[V[i]].emplace_back(U[i], W[i]);
    }
}
 
int getMinimumFuelCapacity(int x, int y) 
{
    x++; y++;
    int l = 0, r = INF + 1, mid;
    while (l < r - 1)
    {
        mid = (l + r) / 2;
        if (!check(x, y, mid)) l = mid;
        else r = mid;
    }
 
    if (r > INF) return -1;
    return r;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 138 ms 12448 KB Output is correct
10 Correct 302 ms 14312 KB Output is correct
11 Correct 361 ms 14320 KB Output is correct
12 Correct 340 ms 14524 KB Output is correct
13 Correct 466 ms 15036 KB Output is correct
14 Execution timed out 2033 ms 12960 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Execution timed out 2044 ms 13224 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Incorrect 3 ms 2652 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 138 ms 12448 KB Output is correct
11 Correct 302 ms 14312 KB Output is correct
12 Correct 361 ms 14320 KB Output is correct
13 Correct 340 ms 14524 KB Output is correct
14 Correct 466 ms 15036 KB Output is correct
15 Incorrect 3 ms 2652 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 138 ms 12448 KB Output is correct
10 Correct 302 ms 14312 KB Output is correct
11 Correct 361 ms 14320 KB Output is correct
12 Correct 340 ms 14524 KB Output is correct
13 Correct 466 ms 15036 KB Output is correct
14 Execution timed out 2033 ms 12960 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2908 KB Output is correct
7 Correct 2 ms 2908 KB Output is correct
8 Correct 2 ms 2908 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 138 ms 12448 KB Output is correct
11 Correct 302 ms 14312 KB Output is correct
12 Correct 361 ms 14320 KB Output is correct
13 Correct 340 ms 14524 KB Output is correct
14 Correct 466 ms 15036 KB Output is correct
15 Execution timed out 2033 ms 12960 KB Time limit exceeded
16 Halted 0 ms 0 KB -