QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#874534 | #3445. Numbers On a Tree | fernandes_queila | Compile Error | / | / | C++98 | 1.4kb | 2025-01-28 10:33:38 | 2025-01-28 10:33:38 |
Judging History
answer
using System;
class TreeNode
{
public int Label { get; set; }
public TreeNode Left { get; set; }
public TreeNode Right { get; set; }
public TreeNode(int label)
{
Label = label;
Left = null;
Right = null;
}
}
class Program
{
static TreeNode BuildTree(int height, ref int currentLabel)
{
if (height < 0)
return null;
TreeNode node = new TreeNode(currentLabel);
currentLabel--;
node.Right = BuildTree(height - 1, ref currentLabel);
node.Left = BuildTree(height - 1, ref currentLabel);
return node;
}
static int SearchNode(TreeNode root, string road)
{
TreeNode currentNode = root;
foreach (char move in road)
{
if (char.ToLower(move) == 'l')
{
currentNode = currentNode.Left;
}
else if (char.ToLower(move) == 'r')
{
currentNode = currentNode.Right;
}
}
return currentNode.Label;
}
static void Main()
{
string line = Console.ReadLine().Trim();
string[] parts = line.Split();
int height = int.Parse(parts[0]);
string road = parts.Length > 1 ? parts[1] : "";
int currentLabel = (int)Math.Pow(2, height + 1) - 1;
TreeNode root = BuildTree(height, ref currentLabel);
Console.WriteLine(SearchNode(root, road));
}
}
Details
answer.code:1:7: error: expected nested-name-specifier before ‘System’ 1 | using System; | ^~~~~~ answer.code:5:11: error: expected ‘:’ before ‘int’ 5 | public int Label { get; set; } | ^~~~ | : answer.code:5:22: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 5 | public int Label { get; set; } | ^ answer.code:5:34: error: expected ‘;’ at end of member declaration 5 | public int Label { get; set; } | ^ | ; answer.code:6:11: error: expected ‘:’ before ‘TreeNode’ 6 | public TreeNode Left { get; set; } | ^~~~~~~~~ | : answer.code:6:21: error: field ‘Left’ has incomplete type ‘TreeNode’ 6 | public TreeNode Left { get; set; } | ^~~~ answer.code:3:7: note: definition of ‘class TreeNode’ is not complete until the closing brace 3 | class TreeNode | ^~~~~~~~ answer.code:6:26: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 6 | public TreeNode Left { get; set; } | ^ answer.code:6:38: error: expected ‘;’ at end of member declaration 6 | public TreeNode Left { get; set; } | ^ | ; answer.code:7:11: error: expected ‘:’ before ‘TreeNode’ 7 | public TreeNode Right { get; set; } | ^~~~~~~~~ | : answer.code:7:21: error: field ‘Right’ has incomplete type ‘TreeNode’ 7 | public TreeNode Right { get; set; } | ^~~~~ answer.code:3:7: note: definition of ‘class TreeNode’ is not complete until the closing brace 3 | class TreeNode | ^~~~~~~~ answer.code:7:27: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 7 | public TreeNode Right { get; set; } | ^ answer.code:7:39: error: expected ‘;’ at end of member declaration 7 | public TreeNode Right { get; set; } | ^ | ; answer.code:9:11: error: expected ‘:’ before ‘TreeNode’ 9 | public TreeNode(int label) | ^~~~~~~~~ | : answer.code:15:2: error: expected ‘;’ after class definition 15 | } | ^ | ; answer.code:5:22: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 5 | public int Label { get; set; } | ^ answer.code:5:24: error: ‘get’ was not declared in this scope 5 | public int Label { get; set; } | ^~~ answer.code:5:27: error: expected ‘}’ before ‘;’ token 5 | public int Label { get; set; } | ^ answer.code:5:22: note: to match this ‘{’ 5 | public int Label { get; set; } | ^ answer.code:5:27: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 5 | public int Label { get; set; } | ^ answer.code:5:27: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘int’ in initialization answer.code:5:27: error: expected ‘;’ before ‘;’ token answer.code: In constructor ‘TreeNode::TreeNode(int)’: answer.code:12:16: error: ‘null’ was not declared in this scope 12 | Left = null; | ^~~~ answer.code: At global scope: answer.code:19:43: error: ‘ref’ has not been declared 19 | static TreeNode BuildTree(int height, ref int currentLabel) | ^~~ answer.code:19:43: error: two or more data types in declaration of ‘currentLabel’ answer.code:33:42: error: ‘string’ has not been declared 33 | static int SearchNode(TreeNode root, string road) | ^~~~~~ answer.code:65:2: error: expected ‘;’ after class definition 65 | } | ^ | ; answer.code: In static member function ‘static TreeNode Program::BuildTree(...)’: answer.code:21:13: error: ‘height’ was not declared in this scope 21 | if (height < 0) | ^~~~~~ answer.code:22:20: error: ‘null’ was not declared in this scope 22 | return null; | ^~~~ answer.code:24:38: error: ‘currentLabel’ was not declared in this scope 24 | TreeNode node = new TreeNode(currentLabel); | ^~~~~~~~~~~~ answer.code:27:32: error: ‘height’ was not declared in this scope 27 | node.Right = BuildTree(height - 1, ref currentLabel); | ...