結果
| 問題 |
No.559 swapAB列
|
| コンテスト | |
| ユーザー |
Risen
|
| 提出日時 | 2017-08-25 22:30:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 810 bytes |
| コンパイル時間 | 895 ms |
| コンパイル使用メモリ | 106,240 KB |
| 実行使用メモリ | 18,560 KB |
| 最終ジャッジ日時 | 2024-10-15 16:00:04 |
| 合計ジャッジ時間 | 1,555 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
コンパイルメッセージ
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;
using static Common;
public static class Common
{
public static void Swap<T>(ref T lhs, ref T rhs)
{
T temp = lhs;
lhs = rhs;
rhs = temp;
}
}
class Solution
{
static void Main()
{
var s = Console.ReadLine().ToArray();
var aCount = s.Count(c => c == 'A');
int count = 0;
while (!s.Take(aCount).All(c => c == 'A'))
{
var target = 0;
for (; true; target++)
{
if (s[target] == 'B' && s[target + 1] == 'A')
{
break;
}
}
Swap(ref s[target], ref s[target + 1]);
count++;
}
Console.WriteLine(count);
}
}
Risen