結果
| 問題 |
No.1328 alligachi-problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-25 01:44:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 1,190 ms / 2,000 ms |
| コード長 | 1,776 bytes |
| コンパイル時間 | 2,726 ms |
| コンパイル使用メモリ | 116,588 KB |
| 実行使用メモリ | 73,656 KB |
| 最終ジャッジ日時 | 2024-09-21 17:24:03 |
| 合計ジャッジ時間 | 19,529 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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], x: v[1], y: int.Parse(v[2]));
})
.ToArray();
var qr = new Queue<(int i, string c, string x, int y)>(cxys.Where(v => v.x == "R").OrderBy(v => v.y).ThenBy(v => v.c));
var qb = new Queue<(int i, string c, string x, int y)>(cxys.Where(v => v.x == "B").OrderBy(v => v.y).ThenByDescending(v => v.c));
var a = new List<int>();
var d = new Dictionary<string, int>();
d["R"] = 0;
d["B"] = 0;
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));
}
}