编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#31190 #2070. 选课 Wrong Answer 0 686 ms 6544 K C++ 11 / 874 B 192022211905 2025-03-16 16:25:22
显示原始代码
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> credits;
vector<vector<int> > adj;
vector<int> dp;

void dfs(int u, int parent) {
    dp[u] = credits[u];
    for (int v : adj[u]) {
        if (v == parent)
            continue;
        dfs(v, u);
        dp[u] += dp[v];
    }
}

int main() {
    int n;
    cin >> n;

    credits.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> credits[i];
    }

    adj.resize(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            int b;
            cin >> b;
            adj[i].push_back(b - 1);  // 转换为0-based
        }
    }

    dp.resize(n, 0);
    dfs(0, -1);

    int max_credits = *max_element(dp.begin(), dp.end());
    cout << max_credits << endl;

    return 0;
}
子任务 #1
Wrong Answer
得分:0
测试点 #1
Wrong Answer
得分:0
用时:74 ms
内存:4508 KiB

输入文件(a1.in

64546
346
911
232
260
204
354
770
686
656
180
492
760
332
73
994
129
292
221
732
<1304086 bytes omitted>

答案文件(a1.out

21980830

用户输出

32760647

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #2
Wrong Answer
得分:0
用时:101 ms
内存:6008 KiB

输入文件(a2.in

87763
360
122
644
448
64
834
996
456
514
928
337
622
831
299
150
359
616
816
573
<1785910 bytes omitted>

答案文件(a2.out

29779119

用户输出

44430520

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #3
Wrong Answer
得分:0
用时:112 ms
内存:6540 KiB

输入文件(a3.in

97101
785
659
469
214
368
744
560
280
670
968
816
272
430
41
500
483
72
216
714

<1980327 bytes omitted>

答案文件(a3.out

33348125

用户输出

49649525

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #4
Wrong Answer
得分:0
用时:114 ms
内存:6544 KiB

输入文件(a4.in

96463
15
109
882
404
711
196
826
474
68
958
551
512
664
306
99
868
80
392
1000
5
<1967031 bytes omitted>

答案文件(a4.out

32960896

用户输出

49119113

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #5
Wrong Answer
得分:0
用时:97 ms
内存:5744 KiB

输入文件(a5.in

84245
394
737
934
484
602
32
127
444
543
384
860
925
416
248
896
432
198
964
400
<1712626 bytes omitted>

答案文件(a5.out

28721378

用户输出

42667086

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #6
Wrong Answer
得分:0
用时:39 ms
内存:2384 KiB

输入文件(a6.in

32637
135
269
88
586
80
410
895
360
898
480
37
686
182
520
877
879
124
167
932
4
<644317 bytes omitted>

答案文件(a6.out

11132180

用户输出

14943938

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #7
Wrong Answer
得分:0
用时:70 ms
内存:4220 KiB

输入文件(a7.in

60741
802
467
361
954
776
84
314
830
338
187
984
625
182
638
194
530
298
546
710
<1225125 bytes omitted>

答案文件(a7.out

20739417

用户输出

30918383

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #8
Wrong Answer
得分:0
用时:19 ms
内存:1288 KiB

输入文件(a8.in

15201
908
169
997
372
674
852
20
800
436
627
620
732
866
516
456
620
806
422
260
<288163 bytes omitted>

答案文件(a8.out

5185111

用户输出

6939140

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #9
Wrong Answer
得分:0
用时:34 ms
内存:2152 KiB

输入文件(a9.in

28101
858
8
80
704
892
252
373
456
748
158
520
237
7
866
976
16
539
288
960
420
<551205 bytes omitted>

答案文件(a9.out

9617080

用户输出

14311989

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #10
Wrong Answer
得分:0
用时:26 ms
内存:1728 KiB

输入文件(a10.in

20685
792
775
818
562
12
216
332
200
872
338
111
432
388
298
96
712
84
256
577
3
<399364 bytes omitted>

答案文件(a10.out

7062131

用户输出

10508772

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0