結果
問題 | No.832 麻雀修行中 |
ユーザー |
![]() |
提出日時 | 2019-05-24 22:36:41 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 2,578 bytes |
コンパイル時間 | 1,117 ms |
コンパイル使用メモリ | 116,464 KB |
実行使用メモリ | 29,940 KB |
最終ジャッジ日時 | 2024-09-17 11:01:12 |
合計ジャッジ時間 | 4,036 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
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;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));}}