結果

問題 No.832 麻雀修行中
ユーザー kuuso1kuuso1
提出日時 2019-05-24 22:36:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 2,578 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 111,956 KB
実行使用メモリ 28,016 KB
最終ジャッジ日時 2023-10-17 12:58:22
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
28,016 KB
testcase_01 AC 54 ms
28,016 KB
testcase_02 AC 52 ms
28,016 KB
testcase_03 AC 58 ms
28,016 KB
testcase_04 AC 64 ms
28,016 KB
testcase_05 AC 64 ms
28,016 KB
testcase_06 AC 64 ms
28,016 KB
testcase_07 AC 66 ms
28,016 KB
testcase_08 AC 64 ms
28,016 KB
testcase_09 AC 61 ms
28,016 KB
testcase_10 AC 61 ms
28,016 KB
testcase_11 AC 62 ms
28,016 KB
testcase_12 AC 65 ms
28,016 KB
testcase_13 AC 67 ms
28,016 KB
testcase_14 AC 57 ms
28,016 KB
testcase_15 AC 64 ms
28,016 KB
testcase_16 AC 59 ms
28,016 KB
testcase_17 AC 55 ms
28,016 KB
testcase_18 AC 65 ms
28,016 KB
testcase_19 AC 60 ms
28,016 KB
testcase_20 AC 57 ms
28,016 KB
testcase_21 AC 62 ms
28,016 KB
testcase_22 AC 62 ms
28,016 KB
testcase_23 AC 55 ms
28,016 KB
testcase_24 AC 66 ms
28,016 KB
testcase_25 AC 60 ms
28,016 KB
testcase_26 AC 64 ms
28,016 KB
testcase_27 AC 51 ms
28,016 KB
testcase_28 AC 67 ms
28,016 KB
testcase_29 AC 38 ms
28,016 KB
testcase_30 AC 59 ms
28,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(){
		
		Three = new List<int[]>();
		for(int i=1;i<=7;i++){
			for(int j=0;j<3;j++){
				Three.Add(new int[]{i,i+1,i+2});
			}
		}
		for(int i=1;i<=9;i++){
			Three.Add(new int[]{i,i,i});
		}
		
		int[] cnt = new int[10];
		for(int i=0;i<S.Length;i++) cnt[S[i] - '0']++;
		
		List<int> ans = new List<int>();
		for(int i=1;i<=9;i++){
			
			cnt[i]++;
			
			bool chk2 = true;
			for(int j=1;j<=9;j++) chk2 &= (cnt[j] % 2) == 0 && cnt[j] != 4;
			if(chk2){
//Console.WriteLine("chk2: i:{0}",i);
				ans.Add(i);
				cnt[i]--;
				continue;
			}
			
			bool chk3 = false;
			for(int a=0;a<Three.Count;a++){
				if(chk3) break;
				for(int b=a+1;b<Three.Count;b++){
					if(chk3) break;
					for(int c=b+1;c<Three.Count;c++){
						if(chk3) break;
						for(int d=c+1;d<Three.Count;d++){
							if(chk3) break;
							
							int[] c0 = new int[10];
							for(int j=0;j<3;j++){
								c0[Three[a][j]]++;
								c0[Three[b][j]]++;
								c0[Three[c][j]]++;
								c0[Three[d][j]]++;
							}
							
							bool chk = true;
							int[] diff = new int[10];
							for(int j=1;j<10;j++){
								if(cnt[j] > 4) chk = false;
								diff[j] = cnt[j] - c0[j];
								if(diff[j] < 0) chk = false;
							}
							if(!chk) continue;
							
							for(int j=1;j<10;j++){
								if(diff[j] == 2) chk3 = true;
							}
/*							if(chk3){
								Console.WriteLine("i:{0}",i);
								Console.WriteLine(String.Join(" ",cnt));
								Console.WriteLine(String.Join(" ",c0));
								Console.WriteLine(String.Join(" ",diff));
							}
*/
						}
					}
				}
			}
			if(chk3){
				ans.Add(i);
			}
			cnt[i]--;
		}
		
		foreach(var n in ans) Console.WriteLine(n);
		
		
		
	}
	
	List<int[]> Three;
	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