From a5b3545b8105c32c637df2ae29b0cfb10b101550 Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Sun, 1 May 2016 14:52:24 +0800 Subject: [PATCH] Just Like another problem. From https://github.com/KiritoTRw/OJ-Problems-Source/blob/master/TYVJ/1813_Brandy.cpp --- QUSTOJ/1031_Brandy.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 QUSTOJ/1031_Brandy.cpp diff --git a/QUSTOJ/1031_Brandy.cpp b/QUSTOJ/1031_Brandy.cpp new file mode 100644 index 0000000..c95f7bc --- /dev/null +++ b/QUSTOJ/1031_Brandy.cpp @@ -0,0 +1,59 @@ +#include + +using namespace std; + +int R, C; +char map[1002][1002]; +int sum = 0; + +int main() { + cin >> R >> C; + char cu; + bool right = true; + for (int i = 1; i <= R; i++) { + for (int j = 1; j <= C; j++) { + cin >> cu; + map[i][j] = cu; + if (cu == '#') { + if (map[i - 1][j] == '#') { + if (map[i][j - 1] == '#' && map[i - 1][j - 1] == '#') { + continue; + } + if (map[i][j - 1] == '#' && map[i - 1][j - 1] != '#') { + right = false; + cout << "Bad placement."; + return 0; + } + if (map[i][j - 1] != '#' && map[i - 1][j - 1] == '#') { + right = false; + cout << "Bad placement."; + return 0; + } + if (map[i][j - 1] != '#' && map[i - 1][j - 1] != '#') { + continue; + } + } else { + if (map[i][j - 1] == '#' && map[i - 1][j - 1] == '#') { + right = false; + cout << "Bad placement."; + return 0; + } + if (map[i][j - 1] == '#' && map[i - 1][j - 1] != '#') { + continue; + } + if (map[i][j - 1] != '#' && map[i - 1][j - 1] == '#') { + sum++; + continue; + } + if (map[i][j - 1] != '#' && map[i - 1][j - 1] != '#') { + sum++; + continue; + } + } + } + } + } + cout << "There are " << sum << " ships."; + //system("pause"); + return 0; +}