답안 #948891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948891 2024-03-18T15:57:44 Z steveonalex 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
2000 ms 85000 KB
#include <bits/stdc++.h>
#include "crocodile.h"

 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

struct P{
    int i; ll w;
    P(){}
    P(int _i, ll _w){i = _i, w = _w;}
};

struct compare{
    bool operator () (P a, P b){return a.w > b.w;}
};

const int N = 1e5 + 69;
const ll INF = 1e18 + 69;
vector<P> graph[N];

int travel_plan(int n, int m, int R[][2], int L[], int K, int E[]){
    for(int i = 0; i<m; ++i){
        int u = R[i][0], v = R[i][1];
        ll w = L[i];
        graph[u].push_back(P(v, w));
        graph[v].push_back(P(u, w));
    }

    vector<ll> dis(n, INF);
    for(int i = 0; i<K; ++i) {
        int u = E[i];
        dis[u] = 0;
    }
    while(true) {
        pair<ll, int> chode = {INF, -1};
        for(int i = 0; i<n; ++i)if (dis[i] == INF){
            pair<ll, ll> mi = {INF, INF};
            for(P v: graph[i]){
                ll val = dis[v.i] + v.w;
                if (mi.first > val){
                    mi.second = mi.first;
                    mi.first = val;
                }
                else minimize(mi.second, val);
            }
            minimize(chode, make_pair(mi.second, i));
        }   
        dis[chode.second] = chode.first;
        if (chode.second == 0) break;
    }
    return dis[0];
}


// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     int R[][2] = {{0,1}, {0,2}, {2,3}, {2,4}};
//     int L[] = {2,3,1,4};
//     int P[] = {1,3,4};
//     cout << travel_plan(5, 4, R, L, 3, P) << "\n";

//     return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6856 KB Output is correct
6 Correct 2 ms 6744 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 3 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6856 KB Output is correct
6 Correct 2 ms 6744 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 3 ms 6744 KB Output is correct
9 Correct 3 ms 7004 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 6 ms 7260 KB Output is correct
13 Correct 4 ms 7300 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 7000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6856 KB Output is correct
6 Correct 2 ms 6744 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 3 ms 6744 KB Output is correct
9 Correct 3 ms 7004 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 6 ms 7260 KB Output is correct
13 Correct 4 ms 7300 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 7000 KB Output is correct
16 Execution timed out 2099 ms 85000 KB Time limit exceeded
17 Halted 0 ms 0 KB -