UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212817#3829. Canruifeng083ms7136kbC++653b2024-10-20 11:47:102024-10-20 12:45:59

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int> > tree;
vector<int> dp;

void dfs(int u, int parent) {
    dp[u] = 1;
    for(int i=0;i<tree[u].size();i++)
	{
		int v=tree[u][i];
        if (v == parent) continue;
        dfs(v, u);
        dp[u] += dp[v];
    }
}

int main() {
    int n;
    cin >> n;
    tree.resize(n + 1);
    dp.resize(n + 1, 0);

    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }

    dfs(1, -1);

    cout << dp[1] << endl;

    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1260kb

input:

5
3 1
1 5
2 4
5 4

output:

5

result:

wrong answer 1st numbers differ - expected: '4', found: '5'

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

100
63 38
17 33
44 12
9 66
21 98
2 49
68 67
75 42
78 25
92 6
67 17
90 19
48 51
83 9
20 94
68 4
64 58...

output:

100

result:

wrong answer 1st numbers differ - expected: '167', found: '100'

Subtask #3:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 1ms
memory: 1320kb

input:

1000
228 978
939 994
911 13
8 806
680 958
779 832
673 924
627 806
354 476
320 218
766 848
171 944
90...

output:

1000

result:

wrong answer 1st numbers differ - expected: '1893', found: '1000'

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 82ms
memory: 7136kb

input:

100000
44881 88880
79640 18741
56510 31493
27649 50461
7015 98523
26337 91384
17594 52397
37312 3409...

output:

100000

result:

wrong answer 1st numbers differ - expected: '199052', found: '100000'

Subtask #5:

score: 0
Time Limit Exceeded

Test #22:

score: 0
Time Limit Exceeded

input:

1000000
198444 939986
569807 470692
847908 557044
739959 80274
772656 222835
832266 382872
267873 10...

output:


result: