253582026-02-19 13:48:15Leventusz09Társasjátékcpp17Wrong answer 0/100272ms17520 KiB
#include <iostream>
#include <limits.h>
#include <vector>
#define int long long

using namespace std;

struct Edge {
    int to;
    int cost;
};

struct Node {
    bool ty = 0;
    bool szomoru;
    int c = -1, oc = -1;
    vector<Edge> et;
} G[100'000];

void cszs(const int&index){
    if(G[index].ty) return;
    G[index].szomoru = 1;
    for(const Edge&e:G[index].et){
        cszs(e.to);
        if(G[e.to].szomoru) G[index].szomoru = 0;
    }

    G[index].ty = 1;
}

void con(const int& index){
    if(G[index].c >= 0) return;
    if(G[index].et.size() == 0){
        G[index].c = 0;
        G[index].oc = 0;
        return;
    }
    if(G[index].szomoru){
        Edge *mt = &G[index].et[1];
        int mc = mt->cost;
        for(Edge& e: G[index].et){
            con(e.to);
            if(G[e.to].c > mc){
                mt = &e;
                mc = G[e.to].c;
            }
        }
        G[index].c = G[mt->to].oc + mt->cost;
        G[index].oc = mc;
        return;
    }
    int mc = LLONG_MAX;
    Edge *mt = &G[index].et[0];
    for(Edge& e: G[index].et){
        if(!G[e.to].szomoru) continue;
        con(e.to);
        if(G[e.to].oc < mc){
            mt = &e;
            mc = G[e.to].oc;
        }
    }
    G[index].c = mc + mt->cost;
    G[index].oc = G[mt->to].c;
}

signed main(){
    int N, M;
    cin >> N >> M;

    for(int i=0; i<M; i++){
        int U, V, W;
        cin >> U >> V >> W;
        U--; V--;
        Edge e;
        e.to = V;
        e.cost = W;
        G[U].et.push_back(e);
    }

    cszs(0);
    con(0);
    if(G[0].szomoru) cout << "Bob" << endl << G[0].oc << endl;
    else cout << "Alice" << endl << G[0].c << endl;

    /*for(int i=0; i<N; i++){
        cout << i +1<< ": " << G[i].szomoru << "\t" << G[i].c << " " << G[i].oc << endl;
    }*/
   return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted4ms4916 KiB
2Accepted263ms10144 KiB
subtask20/10
3Accepted6ms4916 KiB
4Accepted4ms4972 KiB
5Accepted6ms4916 KiB
6Wrong answer4ms4916 KiB
7Wrong answer4ms4876 KiB
subtask30/15
8Wrong answer4ms4916 KiB
9Accepted4ms4916 KiB
10Accepted109ms7612 KiB
11Wrong answer108ms7492 KiB
12Wrong answer101ms7496 KiB
13Accepted203ms9956 KiB
14Accepted224ms10048 KiB
15Wrong answer204ms10128 KiB
16Wrong answer226ms10004 KiB
17Wrong answer203ms10036 KiB
18Wrong answer137ms12912 KiB
19Wrong answer207ms10292 KiB
subtask40/40
20Wrong answer6ms5108 KiB
21Accepted6ms5152 KiB
22Wrong answer104ms7476 KiB
23Wrong answer162ms9012 KiB
24Wrong answer228ms10036 KiB
25Wrong answer225ms10124 KiB
26Accepted210ms10080 KiB
27Wrong answer138ms12708 KiB
28Accepted204ms10304 KiB
subtask50/35
29Accepted6ms4916 KiB
30Accepted257ms10132 KiB
31Accepted6ms4916 KiB
32Accepted4ms4972 KiB
33Accepted6ms4916 KiB
34Wrong answer4ms4916 KiB
35Wrong answer4ms4876 KiB
36Wrong answer4ms4916 KiB
37Accepted4ms4916 KiB
38Accepted109ms7612 KiB
39Wrong answer108ms7492 KiB
40Wrong answer101ms7496 KiB
41Accepted203ms9956 KiB
42Accepted224ms10048 KiB
43Wrong answer204ms10128 KiB
44Wrong answer226ms10004 KiB
45Wrong answer203ms10036 KiB
46Wrong answer137ms12912 KiB
47Wrong answer207ms10292 KiB
48Wrong answer6ms5108 KiB
49Accepted6ms5152 KiB
50Wrong answer104ms7476 KiB
51Wrong answer162ms9012 KiB
52Wrong answer228ms10036 KiB
53Wrong answer225ms10124 KiB
54Accepted210ms10080 KiB
55Wrong answer138ms12708 KiB
56Accepted204ms10304 KiB
57Accepted8ms4916 KiB
58Wrong answer17ms5364 KiB
59Accepted17ms5172 KiB
60Wrong answer268ms10036 KiB
61Wrong answer261ms10116 KiB
62Accepted272ms10036 KiB
63Accepted259ms10036 KiB
64Wrong answer209ms17520 KiB