Submission #60531645


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int h, w, d;
set<pair<int, int>> s;
char arr[1500][1500];
bool visited[1500][1500] = {0};
int direction[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> h >> w >> d;
for (int i = 0; i <= h + 1; i++)
{
for (int j = 0; j <= w + 1; j++)
{
if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
{
arr[i][j] = '#';
}
else
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
int h, w, d;
set<pair<int, int>> s;
char arr[1500][1500];
bool visited[1500][1500] = {0};
int direction[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> d;
    for (int i = 0; i <= h + 1; i++)
    {
        for (int j = 0; j <= w + 1; j++)
        {
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
            {
                arr[i][j] = '#';
            }
            else
            {
                cin >> arr[i][j];
            }
        }
    }
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (arr[i][j] == 'H')
            {
                pq.push({0,{i,j}});
            }
        }
    }
    int ans=0;
    while (pq.empty() == false)
    {
        int step = pq.top().first;
        pair<int, int> coord = pq.top().second;
        pq.pop();
        // cout<<coord.first<<" "<<coord.second<<"\n";
        if(visited[coord.first][coord.second]){
            // cout<<"!!!!";
            continue;
        }
        visited[coord.first][coord.second]=true;
        ans++;
        // cout<<"?";
        if(step+1>d){
            continue;
        }
        // cout<<"/";
        for (int d = 0; d < 4; d++)
        {
            int nextx = coord.first + direction[d][0];
            int nexty = coord.second + direction[d][1];
            if(arr[nextx][nexty]=='.'){
                // cout<<" hi ";
                pq.push({step+1,{nextx,nexty}});
            }
        }
    }
    cout << ans;
}

Submission Info

Submission Time
Task C - Humidifier 3
User fredy
Language C++ 23 (Clang 16.0.6)
Score 350
Code Size 1782 Byte
Status AC
Exec Time 240 ms
Memory 12372 KB

Compile Error

./Main.cpp:6:29: warning: suggest braces around initialization of subobject [-Wmissing-braces]
bool visited[1500][1500] = {0};
                            ^
                            {}
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 39
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3408 KB
00_sample_02.txt AC 1 ms 3540 KB
00_sample_03.txt AC 1 ms 3568 KB
01_test_01.txt AC 199 ms 12364 KB
01_test_02.txt AC 198 ms 12288 KB
01_test_03.txt AC 237 ms 12328 KB
01_test_04.txt AC 235 ms 12292 KB
01_test_05.txt AC 237 ms 12372 KB
01_test_06.txt AC 236 ms 12264 KB
01_test_07.txt AC 240 ms 12320 KB
01_test_08.txt AC 239 ms 12364 KB
01_test_09.txt AC 237 ms 12336 KB
01_test_10.txt AC 237 ms 12320 KB
01_test_11.txt AC 6 ms 6044 KB
01_test_12.txt AC 22 ms 4848 KB
01_test_13.txt AC 3 ms 3604 KB
01_test_14.txt AC 4 ms 5788 KB
01_test_15.txt AC 27 ms 4904 KB
01_test_16.txt AC 58 ms 5296 KB
01_test_17.txt AC 33 ms 5644 KB
01_test_18.txt AC 133 ms 9144 KB
01_test_19.txt AC 77 ms 6764 KB
01_test_20.txt AC 7 ms 3636 KB
01_test_21.txt AC 10 ms 5108 KB
01_test_22.txt AC 11 ms 6464 KB
01_test_23.txt AC 11 ms 6428 KB
01_test_24.txt AC 11 ms 6568 KB
01_test_25.txt AC 10 ms 4980 KB
01_test_26.txt AC 11 ms 6428 KB
01_test_27.txt AC 11 ms 6508 KB
01_test_28.txt AC 11 ms 6428 KB
01_test_29.txt AC 1 ms 3352 KB
01_test_30.txt AC 1 ms 3440 KB
01_test_31.txt AC 1 ms 3424 KB
01_test_32.txt AC 1 ms 3512 KB
01_test_33.txt AC 20 ms 6316 KB
01_test_34.txt AC 34 ms 6380 KB
01_test_35.txt AC 34 ms 6292 KB
01_test_36.txt AC 34 ms 6372 KB


2025-03-05 (Wed)
20:49:38 +00:00