Saratov State University :: Online Contester


::Go
- home
- news
- register
- update personal info
- problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- links
- projects

::Poll
Are you registered on Codeforces?
Yes
No
What is it???

[results]

::webboard

WA1. What is wrong?
Author: mikroz
ID: 059388
Problem: 397
Contest: 0
Date: 2013-09-01 16:42:26

Getting WA1 with Java. Could anybody suggest, what is wrong here?

import java.util.*;
import java.io.*;
import java.math.*;

class DNode
{
DNode next, prev;
char v;
}

public class Solution
{
public static void main(String[] args) throws IOException
{
Scanner in = new Scanner(System.in);

char[] ch = in.next().toCharArray();

DNode node = new DNode();
node.prev = null;
node.next = null;

for (int i = 0; i < ch.length; i++)
switch(ch[i])
{
case 'L':
if (node.prev != null)
node = node.prev;
break;

case 'R':
if (node.next != null)
node = node.next;
break;

default:
DNode newNode = new DNode();

newNode.v = ch[i];
newNode.prev = node;
newNode.next = null;

if (node.next != null)
{
newNode.next = node.next;
node.next.prev = newNode;
}

node.next = newNode;
node = node.next;
break;
}

while (node.prev != null)
node = node.prev;

while (node != null)
{
System.out.print(node.v);
node = node.next;
}
System.out.println();
}
}

see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-22 04:50:35Online Contester Team © 2002 - 2016. All rights reserved.