結果
問題 |
No.452 横着者のビンゴゲーム
|
ユーザー |
![]() |
提出日時 | 2016-12-03 15:33:02 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 843 ms / 3,000 ms |
コード長 | 2,192 bytes |
コンパイル時間 | 4,900 ms |
コンパイル使用メモリ | 108,544 KB |
実行使用メモリ | 25,088 KB |
最終ジャッジ日時 | 2024-11-28 23:11:30 |
合計ジャッジ時間 | 10,006 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
コンパイルメッセージ
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; using System.Threading.Tasks; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ List<HashSet<int>>[] L = new List<HashSet<int>>[M]; for(int t=0;t<M;t++){ L[t] = new List<HashSet<int>>(2*N+2); for(int i=0;i<N;i++){ var b = new HashSet<int>(); for(int j=0;j<N;j++) b.Add(B[t][i][j]); L[t].Add(b); } for(int i=0;i<N;i++){ var b = new HashSet<int>(); for(int j=0;j<N;j++) b.Add(B[t][j][i]); L[t].Add(b); } var bx = new HashSet<int>(); for(int i=0;i<N;i++){ bx.Add(B[t][i][i]); } L[t].Add(bx); var by = new HashSet<int>(); for(int i=0;i<N;i++){ by.Add(B[t][i][N-1-i]); } L[t].Add(by); } int max = 0; int[] maxa = new int[M]; //Parallel.For(0,M,t=>{ for(int t=0;t<M;t++){ foreach(var bs in L[t]){ for(int t2=t+1;t2<M;t2++){ foreach(var bs2 in L[t2]){ maxa[t] = Math.Max(Ovr(bs,bs2),maxa[t]); } } } } //}); max = maxa.Max(); Console.WriteLine(2*N - max -1); } int N,M; int[][][] B; public Sol(){ var d = ria(); N = d[0]; M = d[1]; B = new int[M][][]; for(int i=0;i<M;i++){ B[i] = new int[N][]; for(int j=0;j<N;j++) B[i][j] = ria(); } for(int i=0;i<M;i++) for(int j=0;j<N;j++) for(int k=0;k<N;k++) B[i][j][k]--; } int Ovr(HashSet<int> a, HashSet<int> b){ int ret = 0; foreach(var n in a) if(b.Contains(n))ret++; return ret; } 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));} }