CSES - Datatähti 2024 alku - Results
Submission details
Task:Laskettelukeskus
Sender:Pikaksi
Submission time:2023-11-02 22:44:38 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.00 s1, 2details
#20.00 s1, 2details
#30.00 s1, 2details
#40.13 s2details
#50.13 s2details
#60.00 s1, 2details
#70.10 s2details
#80.00 s1, 2details
#90.12 s2details
#100.00 s1, 2details
#110.12 s2details
#120.00 s1, 2details
#130.12 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:45:9: warning: unused variable 'currentNode' [-Wunused-variable]
   45 |     int currentNode = 0;
      |         ^~~~~~~~~~~
input/code.cpp: In function 'int recursiveSearch(Node)':
input/code.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < node.neighborNodes.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In member function 'Node& Node::operator=(Node&&)',
    inlined from 'int main()' at input/code.cpp:26:24:
input/code.cpp:7:7: warning: '<anonymous>.Node::snowAmount' is used uninitialized [-Wuninitialized]
    7 | class Node
      |       ^~~~
input/code.cpp: In function 'int main()':
input/code.cpp:26:24: note: '<anonymous>' declared here
   26 |     nodeList[0] = Node();
      |                        ^
In copy constructor 'Node::Node(const Node&)',
    i...

Code

#include <iostream>
#include <vector>
using namespace std;

class Node;

class Node
{
public:
    int snowAmount;
    vector<Node> neighborNodes = vector<Node>();
    Node() {

    }
};

int recursiveSearch(Node node);
int numberOfNodes;
Node* nodeList;

int main()
{
    cin >> numberOfNodes;

    nodeList = new Node[numberOfNodes];
    nodeList[0] = Node();

    for (int i = 1; i < numberOfNodes; ++i) {
        // todo: dont always create new number
        int number1;
        int number2;
        cin >> number1;
        cin >> number2;
        Node nodeValue = Node();
        nodeList[number1 - 1].neighborNodes.push_back(nodeValue);
        nodeList[number2 - 1] = nodeValue;
    }

    for (int i = 0; i < numberOfNodes; ++i) {
        int number;
        cin >> number;
        nodeList[i].snowAmount = number;
    }

    int currentNode = 0;
    int ans = recursiveSearch(nodeList[0]);

    cout << ans << endl;

    return 0;
}

int recursiveSearch(Node node)
{
    cout << "node snow amount is " << node.snowAmount << " has " << node.neighborNodes.size() << " neighbor nodes" << endl;

    int snowPlowsNeededBelow = 0;

    for (int i = 0; i < node.neighborNodes.size(); ++i) {
        snowPlowsNeededBelow += recursiveSearch(node.neighborNodes[i]);
    }

    return max(snowPlowsNeededBelow, node.snowAmount);
}

Test details

Test 1

Group: 1, 2

Verdict:

input
5
1 2
1 3
3 4
3 5
...

correct output
6

user output
node snow amount is 0 has 2 ne...
Truncated

Test 2

Group: 1, 2

Verdict:

input
100
1 73
1 64
64 23
1 88
...

correct output
2675

user output
node snow amount is 61 has 3 n...
Truncated

Test 3

Group: 1, 2

Verdict:

input
100
1 36
36 56
56 59
36 97
...

correct output
2808

user output
node snow amount is 65 has 6 n...
Truncated

Test 4

Group: 2

Verdict:

input
100000
1 45452
1 74209
45452 78960
45452 79820
...

correct output
28399367694319

user output
node snow amount is 981018595 ...
Truncated

Test 5

Group: 2

Verdict:

input
100000
1 31165
1 23263
31165 89516
31165 53122
...

correct output
28546840313799

user output
node snow amount is 409055242 ...
Truncated

Test 6

Group: 1, 2

Verdict:

input
100
1 79
79 9
79 45
45 10
...

correct output
0

user output
node snow amount is 0 has 6 ne...
Truncated

Test 7

Group: 2

Verdict:

input
100000
1 66038
1 56789
56789 7403
66038 69542
...

correct output
0

user output
node snow amount is 0 has 12 n...
Truncated

Test 8

Group: 1, 2

Verdict:

input
100
1 2
2 3
3 4
4 5
...

correct output
100

user output
node snow amount is 100 has 1 ...
Truncated

Test 9

Group: 2

Verdict:

input
100000
1 2
2 3
3 4
4 5
...

correct output
1000000000

user output
node snow amount is 1000000000...
Truncated

Test 10

Group: 1, 2

Verdict:

input
100
1 2
1 3
2 4
2 5
...

correct output
2809

user output
node snow amount is 28 has 2 n...
Truncated

Test 11

Group: 2

Verdict:

input
100000
1 2
1 3
2 4
2 5
...

correct output
26053917212428

user output
node snow amount is 19135575 h...
Truncated

Test 12

Group: 1, 2

Verdict:

input
100
1 2
1 3
2 4
2 5
...

correct output
5000

user output
node snow amount is 100 has 2 ...
Truncated

Test 13

Group: 2

Verdict:

input
100000
1 2
1 3
2 4
2 5
...

correct output
50000000000000

user output
node snow amount is 1000000000...
Truncated