結果

問題 No.452 横着者のビンゴゲーム
ユーザー kuuso1kuuso1
提出日時 2016-12-03 01:43:37
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,751 bytes
コンパイル時間 4,391 ms
コンパイル使用メモリ 109,792 KB
実行使用メモリ 38,772 KB
最終ジャッジ日時 2023-08-19 07:04:07
合計ジャッジ時間 53,482 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
24,236 KB
testcase_01 AC 88 ms
24,364 KB
testcase_02 AC 88 ms
24,596 KB
testcase_03 AC 123 ms
24,264 KB
testcase_04 AC 89 ms
24,380 KB
testcase_05 AC 135 ms
26,604 KB
testcase_06 AC 90 ms
24,352 KB
testcase_07 AC 98 ms
26,284 KB
testcase_08 AC 104 ms
24,216 KB
testcase_09 AC 92 ms
26,288 KB
testcase_10 AC 88 ms
24,136 KB
testcase_11 AC 101 ms
26,396 KB
testcase_12 AC 90 ms
26,248 KB
testcase_13 AC 88 ms
26,140 KB
testcase_14 AC 1,555 ms
30,428 KB
testcase_15 AC 1,523 ms
32,144 KB
testcase_16 AC 1,830 ms
33,388 KB
testcase_17 TLE -
testcase_18 AC 617 ms
28,648 KB
testcase_19 AC 1,380 ms
28,516 KB
testcase_20 AC 1,956 ms
32,800 KB
testcase_21 AC 779 ms
26,668 KB
testcase_22 AC 2,259 ms
34,896 KB
testcase_23 AC 979 ms
33,756 KB
testcase_24 AC 2,606 ms
34,684 KB
testcase_25 AC 1,009 ms
26,736 KB
testcase_26 AC 1,169 ms
28,540 KB
testcase_27 AC 2,002 ms
34,800 KB
testcase_28 AC 669 ms
28,556 KB
testcase_29 AC 1,086 ms
28,596 KB
testcase_30 AC 1,005 ms
26,496 KB
testcase_31 AC 581 ms
28,512 KB
testcase_32 AC 983 ms
26,336 KB
testcase_33 AC 1,603 ms
28,728 KB
testcase_34 AC 1,025 ms
28,632 KB
testcase_35 AC 2,133 ms
32,676 KB
testcase_36 AC 1,270 ms
26,484 KB
testcase_37 AC 1,945 ms
32,792 KB
testcase_38 AC 1,643 ms
33,032 KB
testcase_39 AC 1,814 ms
31,740 KB
testcase_40 AC 1,828 ms
31,960 KB
testcase_41 AC 1,819 ms
35,604 KB
testcase_42 AC 1,828 ms
31,596 KB
testcase_43 AC 1,821 ms
31,880 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;
using System.Threading.Tasks;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<BitSet>[] L = new List<BitSet>[M];
		for(int t=0;t<M;t++){
			L[t] = new List<BitSet>(2*N+2);
			for(int i=0;i<N;i++){
				var b = new BitSet();
				for(int j=0;j<N;j++) b.Set(B[t][i][j]);
				L[t].Add(b);
			}
			for(int i=0;i<N;i++){
				var b = new BitSet();
				for(int j=0;j<N;j++) b.Set(B[t][j][i]);
				L[t].Add(b);
			}
			var bx = new BitSet();
			for(int i=0;i<N;i++){
				bx.Set(B[t][i][i]);
			}
			L[t].Add(bx);
			var by = new BitSet();
			for(int i=0;i<N;i++){
				by.Set(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(BitSet.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]--;
	}
	
	class BitSet{
		ulong[] v;
		public BitSet(){
			v = new ulong[625];
		}
		public static int Ovr(BitSet a, BitSet b){
			int ret = 0;
			for(int i=0;i<625;i++){
				ret += PopCnt(a.v[i] & b.v[i]);
			}
			return ret;
		}
		public void Set(int n){
			v[n/64] |= (1UL << (n%64));
		}
		static int PopCnt(ulong x){
			x = (x & 0x5555555555555555L) + (x >> 1 & 0x5555555555555555L);
			x = (x & 0x3333333333333333L) + (x >> 2 & 0x3333333333333333L);
			x = (x & 0x0f0f0f0f0f0f0f0fL) + (x >> 4 & 0x0f0f0f0f0f0f0f0fL);
			x = (x & 0x00ff00ff00ff00ffL) + (x >> 8 & 0x00ff00ff00ff00ffL);
			x = (x & 0x0000ffff0000ffffL) + (x >> 16 & 0x0000ffff0000ffffL);
			return (int)((x & 0x7fffffffL) + (x >>32 & 0x7fffffffL));
    	}
	}
	
	
	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