結果

問題 No.548 国士無双
ユーザー kuuso1
提出日時 2017-07-28 22:30:27
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,343 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 112,628 KB
実行使用メモリ 23,468 KB
最終ジャッジ日時 2024-07-05 20:22:19
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] cnt = new int[26];
		int N = S.Length;
		for(int i=0;i<N;i++) cnt[S[i] - 'a']++;
		
		int sum = 0;
		int two = 0;
		for(int i=0;i<N;i++){
			sum += cnt[i];
			if(cnt[i] == 2) two++;
		}
		if(sum != N || two > 1){
			Console.WriteLine("Impossible");
			return;
		}
		if(two == 0){
			for(int i=0;i<N;i++) Console.WriteLine((char)('a' + i));
			return;
		}
		for(int i=0;i<N;i++){
			if(cnt[i] == 0) Console.WriteLine((char)('a' + i));
		}
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0