首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
jsd
2025年3月12日 20:16
P1564 石油储藏 答疑提问:
P1564
回复 0
|
赞 1
|
浏览 383
#include<bits/stdc++.h> using namespace std; const int maxn = 105; char s[maxn][maxn] = {'*'}; int visited[maxn][maxn] = {0}; int yidong[maxn][maxn] ={{-1,0},{1,0},{0,-1},{0,1}}; struct node{ int x,y; }; int cnt = 0; void bfs(int i,int j){ cnt++; queue<node> q...
RingoCrystal
2025年2月2日 14:02
石油储藏 题解:挖掘解决法
P1564
回复 0
|
赞 10
|
浏览 723
#include <bits/stdc++.h> using namespace std; //挖掘方向 vector<vector<int>> direction {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}}; //找到一个就挖完所有,然后搜剩下的 void dfs(vector<vector<char>>& a, int i, int j) { if (i < 0 || i >...
Candour
2025年1月21日 16:51
石油储藏 (dfs)题解:
P1564
回复 0
|
赞 5
|
浏览 577
#include<bits/stdc++.h> using namespace std; const int N = 110; char g[N][N]; bool st[N][N]; int n, m, cnt; void dfs(int x, int y) { if(x < 0 || x >= n || y < 0 || y >= m || g[x][y] == '*' || st[x][y]) return ; cnt = 1; st[x][y] = true; dfs(x + 1, y); ...
Howie_Waves
2024年9月4日 00:16
石油储藏 题解:
P1564
回复 0
|
赞 10
|
浏览 1.9k
其实这个题不需要用vis数组,访问过的直接用'*'把'#'填了就好了 //AC代码 #include<bits/stdc++.h> using namespace std; int m, n; char mp[105][105]; vector<vector<int>> direction {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}}; int ans; void dfs(int x, int...
damowanghwj
2024年3月16日 15:19
石油储藏 题解:dfs求解
P1564
回复 0
|
赞 2
|
浏览 962
#include<bits/stdc++.h> using namespace std; int m,n; bool isVisit[105][105] = {false}; char a[105][105]; int dir[8][2] = {0,1,1,1,1,0,1,-1,0,-1,-1,-1,-1,0,-1,1}; void dfs(int x,int y){ isVisit[x][y] = true; for(int i = 0;i < 8;i++){ int nx = x + dir[i][0]; ...
猪蹄子全是肉
2023年5月11日 16:37
石油储藏 题解:
P1564
回复 0
|
赞 4
|
浏览 2.1k
#include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; typedef pair<int, int> PII; // 定义一个二元组类型,用于存储坐标 const int N = 110; // 表示地图大小的最大值 int n, m; int d[N][N]; // 存储每个点是否被访问过的状态 char g[N][N]; // 存储地图信息 int r...
jix::c
2023年5月5日 20:07
石油储藏 题解:
P1564
回复 0
|
赞 0
|
浏览 1.2k
泛洪算法,从一个点蔓延到整个连通块。 auto cal = [&](int x,int y) -> void { queue<pair<int,int>> q; q.push({x,y}); str[x][y] = '*'; while(q.size()) { auto t = q.front(); q.pop(); lp(i,0,7) { int nx = dx[i] + t.fi; int ny = dy[i] ...
shmilyzsc
2021年2月24日 14:32
flood fill bfs
P1564
回复 0
|
赞 2
|
浏览 7.0k
总的来说就是搜索到@,利用bfs将相邻的所有@变为* ,直到全部变为* #include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 110; int d[N][N]; char g[N][N]; int n, m; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; void bfs(int sx, in...
James
2021年2月3日 15:46
BFS求连通块个数
P1564
回复 0
|
赞 2
|
浏览 9.4k
#include<iostream> #include<string.h> #include<queue> using namespace std; struct node{ int x,y; }; queue <node> q; int dx[8]={0,0,1,-1,1,-1,1,-1}; int dy[8]={1,-1,0,0,1,1,-1,-1}; int m,n; char map[105][105]; void bfs(int sx,int sy){ &...
wudiyiyi
2020年4月16日 00:08
bfs搜索模板题,求联通块的个数
P1564
回复 0
|
赞 2
|
浏览 7.8k
#include <bits/stdc++.h> using namespace std; const int N=105; bool vis[N][N]; char mp[N][N]; int n,m,dir[][2]={1,0,-1,0,0,1,0,-1,1,1,1,-1,-1,-1,-1,1}; struct node{ int x,y; }; void bfs(int x,int y) { vis[x][y]=1; queue<node> q; &n...
题目
石油储藏
题解数量
10
发布题解
在线答疑
热门题解
1
石油储藏 题解:挖掘解决法
2
石油储藏 题解:
3
石油储藏 (dfs)题解:
4
石油储藏 题解:
5
flood fill bfs
6
石油储藏 题解:dfs求解
7
BFS求连通块个数
8
bfs搜索模板题,求联通块的个数
9
P1564 石油储藏 答疑提问:
10
石油储藏 题解: