Submission #52870949
Source Code Expand
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace atcoder;
namespace mp = boost::multiprecision;
using ll = long long;
using pll = pair<ll,ll>;
using bint = mp::cpp_int;
using mint = modint998244353;
ll H, W;
vector<string> S;
vector<vector<bool>> used;
vector<vector<bool>> used_this_time;
ll dj[] = {0, 1, 0, -1};
ll di[] = {1, 0, -1, 0};
ll dfs(ll i, ll j)
{
if(S[i][j]=='#')
{
return 0LL;
}
if(used_this_time[i][j]==true)
{
return 0LL;
}
used[i][j]=true;
used_this_time[i][j]=true;
ll ret = 1LL;
for(ll a = 0;a < 4;a++)
{
ll ni = i + di[a];
ll nj = j + dj[a];
if(0 <= ni && ni < H && 0 <= nj && nj < W)
{
if(S[ni][nj]=='#')
{
return ret;
}
}
}
for(ll a = 0;a < 4;a++)
{
ll ni = i + di[a];
ll nj = j + dj[a];
if(0 <= ni && ni < H && 0 <= nj && nj < W)
{
ret += dfs(ni, nj);
}
}
return ret;
}
int main()
{
cin >> H >> W;
S.resize(H);
used.resize(H, vector<bool>(W, false));
for(auto& s:S)
{
cin >> s;
}
ll ans = 0LL;
for(ll i = 0;i < H;i++)
{
for(ll j = 0;j < W;j++)
{
if(used[i][j]==false)
{
used_this_time = vector<vector<bool>>(H, vector<bool>(W, false));
ll ret = dfs(i, j);
ans = max(ans, ret);
}
}
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Grid and Magnet |
| User | n0dasalt |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1505 Byte |
| Status | TLE |
| Exec Time | 2208 ms |
| Memory | 68328 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 425 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3532 KiB |
| example_01.txt | AC | 1 ms | 3536 KiB |
| hand_00.txt | AC | 1 ms | 3480 KiB |
| hand_01.txt | AC | 76 ms | 68328 KiB |
| hand_02.txt | TLE | 2207 ms | 5736 KiB |
| hand_03.txt | TLE | 2207 ms | 5752 KiB |
| hand_04.txt | TLE | 2207 ms | 5896 KiB |
| hand_05.txt | AC | 101 ms | 37096 KiB |
| hand_06.txt | AC | 101 ms | 37168 KiB |
| hand_07.txt | AC | 100 ms | 37176 KiB |
| hand_08.txt | AC | 99 ms | 37012 KiB |
| hand_09.txt | AC | 168 ms | 37164 KiB |
| hand_10.txt | AC | 169 ms | 37120 KiB |
| hand_11.txt | AC | 1 ms | 3524 KiB |
| hand_12.txt | AC | 1 ms | 3504 KiB |
| hand_13.txt | AC | 1 ms | 3468 KiB |
| random_00.txt | AC | 973 ms | 55184 KiB |
| random_01.txt | AC | 962 ms | 55044 KiB |
| random_02.txt | AC | 873 ms | 54064 KiB |
| random_03.txt | TLE | 2208 ms | 11984 KiB |
| random_04.txt | TLE | 2208 ms | 12932 KiB |
| random_05.txt | TLE | 2208 ms | 12336 KiB |
| random_06.txt | TLE | 2207 ms | 5720 KiB |
| random_07.txt | TLE | 2207 ms | 5696 KiB |
| random_08.txt | TLE | 2207 ms | 5752 KiB |
| random_09.txt | TLE | 2207 ms | 5720 KiB |
| random_10.txt | TLE | 2207 ms | 5884 KiB |
| random_11.txt | TLE | 2208 ms | 5744 KiB |
| random_12.txt | TLE | 2208 ms | 5736 KiB |
| random_13.txt | TLE | 2208 ms | 5768 KiB |
| random_14.txt | TLE | 2207 ms | 5740 KiB |
| random_15.txt | AC | 78 ms | 67540 KiB |
| random_16.txt | AC | 88 ms | 66060 KiB |
| random_17.txt | AC | 523 ms | 58864 KiB |
| random_18.txt | TLE | 2207 ms | 5728 KiB |
| random_19.txt | TLE | 2207 ms | 5752 KiB |
| random_20.txt | TLE | 2207 ms | 5620 KiB |
| random_21.txt | TLE | 2207 ms | 5748 KiB |
| random_22.txt | TLE | 2207 ms | 5720 KiB |
| random_23.txt | TLE | 2207 ms | 5896 KiB |
| random_24.txt | TLE | 2207 ms | 5724 KiB |
| random_25.txt | TLE | 2207 ms | 5732 KiB |
| random_26.txt | TLE | 2208 ms | 5772 KiB |
| random_27.txt | TLE | 2207 ms | 5740 KiB |
| random_28.txt | TLE | 2207 ms | 5688 KiB |
| random_29.txt | TLE | 2207 ms | 5764 KiB |
| random_30.txt | TLE | 2207 ms | 5820 KiB |
| random_31.txt | TLE | 2207 ms | 5808 KiB |
| random_32.txt | TLE | 2207 ms | 5792 KiB |
| random_33.txt | TLE | 2207 ms | 5748 KiB |
| random_34.txt | TLE | 2207 ms | 5876 KiB |
| random_35.txt | TLE | 2207 ms | 5864 KiB |