Created
May 20, 2012 02:18
-
-
Save dtinth/2733609 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace PreExceed_Karaoke | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<int> l = new List<int>(); | |
Dictionary<int, int> d = new Dictionary<int,int>(); | |
String[] metaStr = Console.ReadLine().Split(' '); | |
int classRooms = int.Parse(metaStr[0]); | |
int students = int.Parse(metaStr[1]); | |
for (int i = 0; i < students; i++) | |
{ | |
String[] dataStr = Console.ReadLine().Split(' '); | |
d[int.Parse(dataStr[1])] = int.Parse(dataStr[0]); | |
} | |
bool a = false; | |
for (;;) | |
{ | |
String[] cmdStr = Console.ReadLine().Split(' '); | |
if (cmdStr[0] == "E") | |
{ | |
int afterIndex = -1; | |
int stdid = int.Parse(cmdStr[1]); | |
int myRoom = d[stdid]; | |
for (int i = 0; i < l.Count; i++) | |
{ | |
int room = d[l[i]]; | |
if (room == myRoom) | |
{ | |
afterIndex = i; | |
} | |
} | |
if (afterIndex == -1) | |
{ | |
l.Add(stdid); | |
} | |
else | |
{ | |
l.Insert(afterIndex + 1, stdid); | |
} | |
} | |
else if (cmdStr[0] == "D") | |
{ | |
if (l.Count == 0) | |
{ | |
Console.WriteLine("empty"); | |
} | |
else | |
{ | |
Console.WriteLine(l[0]); | |
l.RemoveAt(0); | |
} | |
} | |
else if (cmdStr[0] == "X") | |
{ | |
Console.WriteLine("0"); | |
Console.ReadLine(); | |
return; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment