Submission #1135437
Source Code Expand
#include <cstdio> #include <cstdlib> #include <iostream> #include <fstream> #include <sstream> #include <set> #include <map> #include <vector> #include <list> #include <algorithm> #include <cstring> #include <cmath> #include <string> #include <queue> #include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic #include <cassert> #include <iomanip> //do setprecision #include <ctime> #include <complex> using namespace std; #define FOR(i,b,e) for(int i=(b);i<(e);++i) #define FORQ(i,b,e) for(int i=(b);i<=(e);++i) #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i) #define REP(x, n) for(int x = 0; x < (n); ++x) #define ST first #define ND second #define PB push_back #define MP make_pair #define LL long long #define ULL unsigned LL #define LD long double const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342; const int MR = 510; char s[MR][MR]; bool isBlack[MR]; int main() { int N; scanf("%d", &N); REP(i,N) scanf("%s", s[i]); // spr czy cala biala plansza bool white = 1; REP(i,N)REP(j,N) if(s[i][j] == '#') white = 0; if(white) { printf("-1\n"); return 0; } // ile kolumn zlych int bad = 0; REP(i,N)REP(j,N) if(s[j][i] == '.') { bad++; break; } // na jakich pozycjach sa czarne wiersze // zauwaz, ze jesli na danej pozycji nie ma czarnego wiersza // mozna to zrobic w 1 ruchu, jesli plansza nie jest cala biala REP(i,N)REP(j,N) if(s[j][i] == '#') { isBlack[i] = 1; break; } int res = MR; REP(i,N) { int ile = 0; REP(j,N) if(s[i][j] == '.') ile++; // jesli na danej pozycji nie bylo czarnego wiersza, musisz wykonac 1 ruch, zeby go zrobic if(!isBlack[i]) ile++; res = min(res, ile); } // dodaj liczbe zlych kolumn na poczatku res += bad; printf("%d\n", res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Row to Column |
User | pdwd |
Language | C++14 (GCC 5.4.1) |
Score | 1300 |
Code Size | 1973 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:46:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:48:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", s[i]); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 1000 / 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 | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
0_04.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 1 ms | 256 KB |
1_11.txt | AC | 1 ms | 256 KB |
1_12.txt | AC | 1 ms | 256 KB |
1_13.txt | AC | 1 ms | 256 KB |
1_14.txt | AC | 1 ms | 256 KB |
2_00.txt | AC | 2 ms | 512 KB |
2_01.txt | AC | 2 ms | 512 KB |
2_02.txt | AC | 2 ms | 512 KB |
2_03.txt | AC | 2 ms | 512 KB |
2_04.txt | AC | 2 ms | 512 KB |
2_05.txt | AC | 2 ms | 512 KB |
2_06.txt | AC | 2 ms | 512 KB |
2_07.txt | AC | 2 ms | 512 KB |
2_08.txt | AC | 2 ms | 512 KB |
2_09.txt | AC | 2 ms | 512 KB |
2_10.txt | AC | 2 ms | 512 KB |
2_11.txt | AC | 2 ms | 512 KB |
2_12.txt | AC | 2 ms | 512 KB |
2_13.txt | AC | 2 ms | 512 KB |
2_14.txt | AC | 2 ms | 512 KB |
2_15.txt | AC | 2 ms | 512 KB |
2_16.txt | AC | 2 ms | 512 KB |
2_17.txt | AC | 2 ms | 512 KB |
2_18.txt | AC | 2 ms | 384 KB |
2_19.txt | AC | 2 ms | 512 KB |
2_20.txt | AC | 2 ms | 384 KB |
2_21.txt | AC | 2 ms | 384 KB |
2_22.txt | AC | 2 ms | 512 KB |