229172026-01-16 08:49:22Leventusz09Városnézéscpp17Wrong answer 0/80565ms262144 KiB
#include <iostream>
#include <vector>
#include <stdint.h>

using namespace std;

struct Ter {
    vector<uint32_t> et;
    //vector<uint32_t> ef;
    uint32_t n;  // látványosságok száma
    uint32_t an = 0; // sok látványosság
    uint32_t ob; // előző elem
};


int main(){
    Ter terek[20'000];
    uint32_t N, M;
    cin >> N >> M;

    for(uint32_t i=0; i<N; i++) cin >> terek[i].n;

    for(uint32_t i=0; i<M; i++){
        uint32_t t1, t2;
        cin >> t1 >> t2;
        terek[t1-1].et.push_back(t2-1);
        //terek[t2-1].ef.push_back(t1-1);
    }

    terek[0].an = terek[0].n;
    vector<uint32_t> q;
    q.push_back(0);
    uint32_t si= 0;
    while(si < N-1){
        for(uint32_t&x:terek[q[si]].et){
            q.push_back(x);
            if(terek[x].an < terek[q[si]].an + terek[x].n) {
                terek[x].an = terek[q[si]].an + terek[x].n;
                terek[x].ob = q[si];
            }
        }
        si++;
    }

    cout << terek[q[q.size() - 1]].an << endl;
    vector<uint32_t> o1;
    for(uint32_t i=q[q.size() - 1]; i != 0; i = terek[i].ob) o1.push_back(i+1);
    cout << 1 << " ";
    for(int32_t i = o1.size()-1; i >= 0; i--) cout << o1[i] << " ";
    cout << endl;

}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted2ms1260 KiB
subtask20/20
2Accepted2ms1072 KiB
3Accepted2ms1316 KiB
4Wrong answer2ms1320 KiB
5Wrong answer6ms1332 KiB
6Wrong answer3ms1180 KiB
7Wrong answer8ms1332 KiB
8Wrong answer8ms1220 KiB
9Accepted2ms1076 KiB
10Wrong answer14ms1528 KiB
11Wrong answer2ms1100 KiB
12Accepted1ms1040 KiB
subtask30/25
13Accepted2ms1260 KiB
14Accepted2ms1268 KiB
15Accepted2ms1076 KiB
16Wrong answer2ms1076 KiB
17Runtime error541ms262144 KiB
18Wrong answer2ms1076 KiB
19Runtime error430ms262144 KiB
20Runtime error2ms1180 KiB
21Runtime error2ms1076 KiB
22Wrong answer4ms1076 KiB
23Runtime error3ms1076 KiB
24Wrong answer4ms1076 KiB
25Wrong answer3ms1076 KiB
26Runtime error3ms1192 KiB
27Wrong answer4ms1092 KiB
28Wrong answer26ms1660 KiB
29Wrong answer6ms1076 KiB
30Wrong answer28ms1544 KiB
31Runtime error446ms262144 KiB
32Runtime error565ms262144 KiB
33Runtime error9ms1076 KiB
subtask40/20
34Accepted2ms1080 KiB
35Wrong answer2ms1076 KiB
36Accepted2ms1076 KiB
37Wrong answer2ms1076 KiB
38Wrong answer2ms1076 KiB
39Runtime error544ms262144 KiB
40Wrong answer2ms1076 KiB
41Runtime error432ms262144 KiB
42Runtime error3ms1076 KiB
43Runtime error2ms1268 KiB
44Wrong answer2ms1076 KiB
45Runtime error428ms262144 KiB
46Wrong answer2ms1076 KiB
47Wrong answer2ms1076 KiB
48Runtime error2ms1076 KiB
49Wrong answer2ms1076 KiB
50Accepted2ms1076 KiB
51Wrong answer2ms1268 KiB
52Wrong answer1ms1076 KiB
53Wrong answer1ms1076 KiB
54Accepted2ms1076 KiB
55Wrong answer2ms1076 KiB
56Wrong answer2ms1100 KiB
57Wrong answer2ms1040 KiB
58Wrong answer2ms1076 KiB
59Wrong answer2ms1076 KiB
60Accepted1ms1076 KiB
61Wrong answer2ms1076 KiB
62Wrong answer2ms1076 KiB
63Wrong answer2ms1172 KiB
64Wrong answer2ms1076 KiB
65Wrong answer2ms1076 KiB
66Wrong answer2ms1076 KiB
subtask50/15
67Accepted2ms1080 KiB
68Accepted2ms1072 KiB
69Accepted2ms1316 KiB
70Wrong answer2ms1320 KiB
71Wrong answer6ms1332 KiB
72Wrong answer3ms1180 KiB
73Wrong answer8ms1332 KiB
74Wrong answer8ms1220 KiB
75Accepted2ms1076 KiB
76Wrong answer14ms1528 KiB
77Wrong answer2ms1100 KiB
78Accepted1ms1040 KiB
79Accepted2ms1260 KiB
80Accepted2ms1268 KiB
81Accepted2ms1076 KiB
82Wrong answer2ms1076 KiB
83Runtime error541ms262144 KiB
84Wrong answer2ms1076 KiB
85Runtime error430ms262144 KiB
86Runtime error2ms1180 KiB
87Runtime error2ms1076 KiB
88Wrong answer4ms1076 KiB
89Runtime error3ms1076 KiB
90Wrong answer4ms1076 KiB
91Wrong answer3ms1076 KiB
92Runtime error3ms1192 KiB
93Wrong answer4ms1092 KiB
94Wrong answer26ms1660 KiB
95Wrong answer6ms1076 KiB
96Wrong answer28ms1544 KiB
97Runtime error446ms262144 KiB
98Runtime error565ms262144 KiB
99Runtime error9ms1076 KiB
100Wrong answer2ms1076 KiB
101Accepted2ms1076 KiB
102Wrong answer2ms1076 KiB
103Wrong answer2ms1076 KiB
104Runtime error544ms262144 KiB
105Wrong answer2ms1076 KiB
106Runtime error432ms262144 KiB
107Runtime error3ms1076 KiB
108Runtime error2ms1268 KiB
109Wrong answer2ms1076 KiB
110Runtime error428ms262144 KiB
111Wrong answer2ms1076 KiB
112Wrong answer2ms1076 KiB
113Runtime error2ms1076 KiB
114Wrong answer2ms1076 KiB
115Accepted2ms1076 KiB
116Wrong answer2ms1268 KiB
117Wrong answer1ms1076 KiB
118Wrong answer1ms1076 KiB
119Accepted2ms1076 KiB
120Wrong answer2ms1076 KiB
121Wrong answer2ms1100 KiB
122Wrong answer2ms1040 KiB
123Wrong answer2ms1076 KiB
124Wrong answer2ms1076 KiB
125Accepted1ms1076 KiB
126Wrong answer2ms1076 KiB
127Wrong answer2ms1076 KiB
128Wrong answer2ms1172 KiB
129Wrong answer2ms1076 KiB
130Wrong answer2ms1076 KiB
131Wrong answer2ms1076 KiB
132Wrong answer4ms1076 KiB
133Runtime error3ms1368 KiB
134Wrong answer4ms1032 KiB
135Wrong answer3ms1080 KiB
136Wrong answer3ms1200 KiB
137Wrong answer3ms1192 KiB
138Wrong answer4ms1076 KiB
139Wrong answer3ms1296 KiB
140Wrong answer6ms1332 KiB
141Wrong answer3ms1264 KiB
142Wrong answer8ms1332 KiB
143Wrong answer9ms1332 KiB
144Wrong answer12ms1576 KiB
145Wrong answer8ms1440 KiB
146Wrong answer20ms1912 KiB
147Wrong answer17ms1532 KiB
148Wrong answer16ms1500 KiB
149Wrong answer10ms1464 KiB