結果
| 問題 |
No.452 横着者のビンゴゲーム
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-12-03 01:43:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,751 bytes |
| コンパイル時間 | 2,345 ms |
| コンパイル使用メモリ | 114,436 KB |
| 実行使用メモリ | 36,496 KB |
| 最終ジャッジ日時 | 2024-11-28 21:28:42 |
| 合計ジャッジ時間 | 48,682 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 TLE * 1 |
コンパイルメッセージ
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<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));}
}
kuuso1