結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-06 16:52:12 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 672 bytes |
| コンパイル時間 | 1,512 ms |
| コンパイル使用メモリ | 109,800 KB |
| 実行使用メモリ | 123,440 KB |
| 最終ジャッジ日時 | 2024-11-07 04:02:25 |
| 合計ジャッジ時間 | 7,655 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 1 TLE * 1 -- * 19 |
コンパイルメッセージ
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;
class SwapString
{
static void Main(String[] args)
{
String S = Console.ReadLine();
Queue<String> countQueue = new Queue<String>();
Queue<String> uniqueQueue = new Queue<String>();
countQueue.Enqueue(S);
while(countQueue.Count > 0)
{
String s = countQueue.Dequeue();
if(!uniqueQueue.Contains(s))
{
uniqueQueue.Enqueue(s);
for(int i=0; i < s.Length-1; i++)
{
char[] arr = s.ToCharArray();
char temp = arr[i+1];
arr[i+1] = arr[i];
arr[i] = temp;
String t = new String(arr);
countQueue.Enqueue(t);
}
}
}
Console.WriteLine(uniqueQueue.Count-1);
}
}