結果
| 問題 | 
                            No.1328 alligachi-problem
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-25 01:53:41 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 389 ms / 2,000 ms | 
| コード長 | 1,734 bytes | 
| コンパイル時間 | 905 ms | 
| コンパイル使用メモリ | 112,548 KB | 
| 実行使用メモリ | 45,120 KB | 
| 最終ジャッジ日時 | 2024-09-21 17:25:00 | 
| 合計ジャッジ時間 | 12,736 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Y
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var cxys = new bool[n]
			.Select((_, i) =>
			{
				var v = Console.ReadLine().Split();
				return (i: i + 1, c: v[0] == "R" ? 0 : 1, x: v[1] == "R" ? 0 : 1, y: int.Parse(v[2]));
			})
			.ToArray();
		var qr = new Queue<(int i, int c, int x, int y)>(cxys.Where(v => v.x == 0).OrderBy(v => v.y).ThenBy(v => -v.c));
		var qb = new Queue<(int i, int c, int x, int y)>(cxys.Where(v => v.x == 1).OrderBy(v => v.y).ThenBy(v => v.c));
		var a = new List<int>();
		var d = new int[2];
		while (qr.Count > 0 || qb.Count > 0)
		{
			if (qr.Count == 0)
			{
				var v = qb.Dequeue();
				if (d[v.x] != v.y) { Console.WriteLine("No"); return; }
				a.Add(v.i);
				d[v.c]++;
			}
			else if (qb.Count == 0)
			{
				var v = qr.Dequeue();
				if (d[v.x] != v.y) { Console.WriteLine("No"); return; }
				a.Add(v.i);
				d[v.c]++;
			}
			else
			{
				var vr = qr.Peek();
				var vb = qb.Peek();
				if (d[vr.x] != vr.y && d[vb.x] != vb.y) { Console.WriteLine("No"); return; }
				if (d[vr.x] != vr.y)
				{
					qb.Dequeue();
					a.Add(vb.i);
					d[vb.c]++;
				}
				else if (d[vb.x] != vb.y)
				{
					qr.Dequeue();
					a.Add(vr.i);
					d[vr.c]++;
				}
				else
				{
					if (vr.c == vr.x && vb.c == vb.x || vr.c != vr.x && vb.c != vb.x)
					{
						qr.Dequeue();
						a.Add(vr.i);
						d[vr.c]++;
					}
					else
					{
						if (vr.c == vr.x)
						{
							qr.Dequeue();
							a.Add(vr.i);
							d[vr.c]++;
						}
						else
						{
							qb.Dequeue();
							a.Add(vb.i);
							d[vb.c]++;
						}
					}
				}
			}
		}
		Console.WriteLine("Yes\n" + string.Join(" ", a));
	}
}