Submission #46984145
Source Code Expand
#include <bits/stdc++.h> #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using int64 = long long; using uint = unsigned int; using uint64 = unsigned long long; bool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; } bool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; } using namespace std; const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<string> board(n); for (int i = 0; i < n; i++) cin >> board[i]; vector vt(n, vector<int>(m)); int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (board[i][j] == '#' && !vt[i][j]) { ans++; vt[i][j] = true; vector<pair<int, int>> que = {{i, j}}; for (int t = 0; t < (int)que.size(); t++) { auto [x, y] = que[t]; for (int d = 0; d < 8; d++) { int x2 = x + dx[d], y2 = y + dy[d]; if (x2 < 0 || x2 >= n || y2 < 0 || y2 >= m) continue; if (board[x2][y2] != '#' || vt[x2][y2]) continue; vt[x2][y2] = true; que.push_back({x2, y2}); } } } } } cout << ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Sensors |
User | xindubawukong |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 1323 Byte |
Status | AC |
Exec Time | 46 ms |
Memory | 12372 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt, sample03.txt |
All | sample00.txt, sample01.txt, sample02.txt, sample03.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 3468 KiB |
sample01.txt | AC | 1 ms | 3612 KiB |
sample02.txt | AC | 1 ms | 3528 KiB |
sample03.txt | AC | 1 ms | 3516 KiB |
testcase00.txt | AC | 21 ms | 12112 KiB |
testcase01.txt | AC | 21 ms | 12372 KiB |
testcase02.txt | AC | 19 ms | 11584 KiB |
testcase03.txt | AC | 21 ms | 12324 KiB |
testcase04.txt | AC | 19 ms | 11800 KiB |
testcase05.txt | AC | 21 ms | 12332 KiB |
testcase06.txt | AC | 20 ms | 11856 KiB |
testcase07.txt | AC | 19 ms | 9972 KiB |
testcase08.txt | AC | 18 ms | 9500 KiB |
testcase09.txt | AC | 21 ms | 12308 KiB |
testcase10.txt | AC | 20 ms | 12020 KiB |
testcase11.txt | AC | 21 ms | 12344 KiB |
testcase12.txt | AC | 16 ms | 12352 KiB |
testcase13.txt | AC | 14 ms | 11468 KiB |
testcase14.txt | AC | 14 ms | 9812 KiB |
testcase15.txt | AC | 13 ms | 7832 KiB |
testcase16.txt | AC | 4 ms | 7500 KiB |
testcase17.txt | AC | 10 ms | 8072 KiB |
testcase18.txt | AC | 10 ms | 8092 KiB |
testcase19.txt | AC | 8 ms | 7640 KiB |
testcase20.txt | AC | 9 ms | 8096 KiB |
testcase21.txt | AC | 14 ms | 7320 KiB |
testcase22.txt | AC | 16 ms | 8088 KiB |
testcase23.txt | AC | 23 ms | 7900 KiB |
testcase24.txt | AC | 24 ms | 8108 KiB |
testcase25.txt | AC | 31 ms | 8316 KiB |
testcase26.txt | AC | 34 ms | 8912 KiB |
testcase27.txt | AC | 41 ms | 11800 KiB |
testcase28.txt | AC | 46 ms | 12312 KiB |