Submission #3179542
Source Code Expand
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { string str = Console.ReadLine(); long N = long.Parse(str); long[,] A = new long[N,N]; for(var i=0;i<N;i++){ string str2 = Console.ReadLine(); for(var j=0;j<str2.Length;j++){ if(str2.Substring(j,1) == "#"){ A[i,j] = 1; } } } long ans = 0; long[] C1 = new long[N]; long[] C2 = new long[N]; long c1max = 0; long c1min = N; for(var i=0;i<N;i++){ for(var j=0;j<N;j++){ if(A[i,j] == 1){ C1[i] += 1; } } c1max = Math.Max(c1max,C1[i]); c1min = Math.Min(c1min,C1[i]); } long c2max = 0; long c2min = N; long c2maxct = 0; for(var i=0;i<N;i++){ for(var j=0;j<N;j++){ if(A[j,i] == 1){ C2[i] += 1; } } if(C2[i] == N){ c2maxct += 1; } c2max = Math.Max(c2max,C2[i]); c2min = Math.Min(c2min,C2[i]); } if(c1max == 0){ ans = -1; } else { if(c1max == N){ ans += N - c2maxct; } else { long ctmin = N; for(var i=0;i<N;i++){ if(C1[i] > 0){ for(var j=0;j<N;j++){ if(A[i,j] == 1){ long ct = N - C1[j]; ctmin = Math.Min(ctmin,ct); } } } } ans += ctmin; ans += N - c2maxct; } if(c1max == N-1 && c2min == 0){ ans = Math.Min(ans,N - c2maxct + 2); } } Console.WriteLine(ans); } }
Submission Info
Submission Time | |
---|---|
Task | B - Row to Column |
User | miku |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 1444 Byte |
Status | WA |
Exec Time | 50 ms |
Memory | 17348 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 0 / 1000 | ||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
Subtask | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 21 ms | 13140 KB |
0_01.txt | AC | 21 ms | 11092 KB |
0_02.txt | AC | 20 ms | 9172 KB |
0_03.txt | AC | 20 ms | 9044 KB |
0_04.txt | AC | 20 ms | 9044 KB |
1_00.txt | AC | 20 ms | 9044 KB |
1_01.txt | AC | 20 ms | 11092 KB |
1_02.txt | AC | 20 ms | 11220 KB |
1_03.txt | AC | 20 ms | 9172 KB |
1_04.txt | AC | 20 ms | 9044 KB |
1_05.txt | AC | 20 ms | 9044 KB |
1_06.txt | AC | 21 ms | 13140 KB |
1_07.txt | AC | 20 ms | 9044 KB |
1_08.txt | AC | 20 ms | 9044 KB |
1_09.txt | AC | 20 ms | 9044 KB |
1_10.txt | AC | 20 ms | 9044 KB |
1_11.txt | AC | 20 ms | 9044 KB |
1_12.txt | AC | 20 ms | 11092 KB |
1_13.txt | AC | 20 ms | 11092 KB |
1_14.txt | AC | 20 ms | 11092 KB |
2_00.txt | AC | 44 ms | 13256 KB |
2_01.txt | AC | 46 ms | 14940 KB |
2_02.txt | AC | 45 ms | 15304 KB |
2_03.txt | AC | 44 ms | 13252 KB |
2_04.txt | AC | 44 ms | 15300 KB |
2_05.txt | AC | 45 ms | 13256 KB |
2_06.txt | WA | 45 ms | 17348 KB |
2_07.txt | AC | 41 ms | 14300 KB |
2_08.txt | AC | 50 ms | 14812 KB |
2_09.txt | AC | 46 ms | 16860 KB |
2_10.txt | AC | 46 ms | 14812 KB |
2_11.txt | AC | 50 ms | 17252 KB |
2_12.txt | AC | 48 ms | 14812 KB |
2_13.txt | AC | 46 ms | 16604 KB |
2_14.txt | WA | 46 ms | 16732 KB |
2_15.txt | AC | 41 ms | 14172 KB |
2_16.txt | AC | 43 ms | 16092 KB |
2_17.txt | AC | 40 ms | 16092 KB |
2_18.txt | AC | 37 ms | 15240 KB |
2_19.txt | AC | 44 ms | 14812 KB |
2_20.txt | AC | 37 ms | 14172 KB |
2_21.txt | AC | 36 ms | 14176 KB |
2_22.txt | AC | 46 ms | 14812 KB |