Submission #52864852
Source Code Expand
Copy
#include<bits/stdc++.h>#define ll long long#define INF 0x3f3f3f3f#define endl '\n'using namespace std;const int N = 1e3 + 233;int h,w,ans = -1;int f[N][N];bool vis[N][N];int fx[4] = {1,-1,0,0};int fy[4] = {0,0,1,-1};char ch[N][N];int dfs(int x,int y){int ans = 0;if(f[x][y]) return f[x][y];for(int i=0;i<4;i++)for(int j=0;j<4;j++)
#include<bits/stdc++.h> #define ll long long #define INF 0x3f3f3f3f #define endl '\n' using namespace std; const int N = 1e3 + 233; int h,w,ans = -1; int f[N][N]; bool vis[N][N]; int fx[4] = {1,-1,0,0}; int fy[4] = {0,0,1,-1}; char ch[N][N]; int dfs(int x,int y){ int ans = 0; if(f[x][y]) return f[x][y]; for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(ch[x+fx[i]][y+fy[i]] == '#') return 1; for(int i=0;i<4;i++){ int nx = x + fx[i]; int ny = y + fy[i]; if(1<=nx&&nx<=h && 1<=ny&&ny<=w && ch[nx][ny] == '.' && !vis[nx][ny]){ vis[nx][ny] = 1; ans += dfs(nx,ny); vis[nx][ny] = 0; } } // cout<<x<<" "<<y<<" "<<ans<<endl; return f[x][y] = ans; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>h>>w; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ cin>>ch[i][j]; } } for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ if(ch[i][j] == '.'){ // cout<<i<<" "<<j<<" "<<dfs(i,j)<<endl; ans = max(ans , dfs(i,j)); } } } cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Grid and Magnet |
User | wusixie |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 1099 Byte |
Status | WA |
Exec Time | 2216 ms |
Memory | 103728 KB |
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 | 3484 KB |
example_01.txt | AC | 1 ms | 3424 KB |
hand_00.txt | AC | 1 ms | 3476 KB |
hand_01.txt | TLE | 2213 ms | 103340 KB |
hand_02.txt | AC | 9 ms | 4728 KB |
hand_03.txt | AC | 11 ms | 4808 KB |
hand_04.txt | WA | 28 ms | 10812 KB |
hand_05.txt | TLE | 2212 ms | 88120 KB |
hand_06.txt | TLE | 2212 ms | 88044 KB |
hand_07.txt | TLE | 2216 ms | 102924 KB |
hand_08.txt | TLE | 2213 ms | 103728 KB |
hand_09.txt | TLE | 2210 ms | 54316 KB |
hand_10.txt | TLE | 2210 ms | 54164 KB |
hand_11.txt | WA | 1 ms | 3436 KB |
hand_12.txt | AC | 1 ms | 3380 KB |
hand_13.txt | WA | 1 ms | 3484 KB |
random_00.txt | TLE | 2208 ms | 21500 KB |
random_01.txt | TLE | 2212 ms | 20632 KB |
random_02.txt | TLE | 2208 ms | 18688 KB |
random_03.txt | WA | 48 ms | 15688 KB |
random_04.txt | WA | 48 ms | 17056 KB |
random_05.txt | WA | 50 ms | 15320 KB |
random_06.txt | WA | 39 ms | 10600 KB |
random_07.txt | WA | 38 ms | 10664 KB |
random_08.txt | WA | 38 ms | 10680 KB |
random_09.txt | WA | 25 ms | 10652 KB |
random_10.txt | WA | 24 ms | 10628 KB |
random_11.txt | WA | 25 ms | 10544 KB |
random_12.txt | AC | 10 ms | 4604 KB |
random_13.txt | AC | 10 ms | 4680 KB |
random_14.txt | AC | 10 ms | 4608 KB |
random_15.txt | TLE | 2213 ms | 101624 KB |
random_16.txt | TLE | 2212 ms | 84252 KB |
random_17.txt | TLE | 2209 ms | 27316 KB |
random_18.txt | AC | 9 ms | 4652 KB |
random_19.txt | AC | 9 ms | 4612 KB |
random_20.txt | AC | 10 ms | 4672 KB |
random_21.txt | WA | 11 ms | 4588 KB |
random_22.txt | WA | 11 ms | 5148 KB |
random_23.txt | WA | 13 ms | 10004 KB |
random_24.txt | WA | 21 ms | 9772 KB |
random_25.txt | WA | 21 ms | 9764 KB |
random_26.txt | WA | 23 ms | 10700 KB |
random_27.txt | WA | 21 ms | 9852 KB |
random_28.txt | WA | 22 ms | 9668 KB |
random_29.txt | WA | 21 ms | 10460 KB |
random_30.txt | WA | 31 ms | 10232 KB |
random_31.txt | WA | 28 ms | 10428 KB |
random_32.txt | WA | 28 ms | 10596 KB |
random_33.txt | WA | 29 ms | 10220 KB |
random_34.txt | WA | 29 ms | 10596 KB |
random_35.txt | WA | 29 ms | 11000 KB |