ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2002. Test Task

Runtime error 4
Posted by Nextatix 1 May 2015 19:59
switch(in.sval)
            {
                case "register":
                    {
                        in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval);
                        in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval);
                        if(m.containsKey(log)) out.println("fail: user already exists");
                        else
                        {
                            m.put(log,pas);
                            out.println("success: new user added");
                        }
                    }
                    break;
                case "login":
                    {
                        in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval);
                        in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval);
                        if(!m.containsKey(log)) out.println("fail: no such user");
                        else if(!m.get(log).equals(pas)) out.println("fail: incorrect password");
                        else if(a.contains(log)) out.println("fail: already logged in");
                        else
                        {
                            a.add(log); //out.println(m.get(log) + " " + pas);
                            out.println("success: user logged in");
                        }
                    }
                    break;
                case "logout":
                    {
                        in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval);
                        if(!m.containsKey(log)) out.println("fail: no such user");
                        else if(!a.contains(log)) out.println("fail: already logged out");
                        else
                        {
                            a.remove(log);
                            out.println("success: user logged out");
                        }
                    }
                    break;

            }