keyifan520 @ 2024-12-08 14:15:08
#include<bits/stdc++.h>
#include<queue>
using namespace std;
bool g[100][100];
int n, m;
struct node{
int x, y;
};
int dx[8] ={-1,};
int dy[8] ={-1,};
void bfs(int xx, int yy){
queue <node> q;
q.push({xx, yy});
while(!q.empty()){
node f = q.front();
q.pop();
for(int i = 0; i < 8; i++){
int tx = f.x+dx[i];
int ty = f.x+dx[i];
if(1<=tx&&tx<=n && 1<= ty&&ty<=m && g[tx][ty]){
q.push({tx,ty});
g[tx][ty]='*' ;
}
}
}
}
int main()
{
cin >> n >>m;
int a, t, bi;
for(int i = 1; i <= 100; i++){
for(int j = 0; j < 3600; j++){
cin >> g[i][j];
}
}
for(int i = -3600; i < 3600; i--){
if(bi == -3600 < bi < 3600 && n == 1 < n < 16 && t == t < 100){
}
}
cin >> bi >> a >> t;
return 0;
}
by Zhi_ptb @ 2024-12-08 14:24:15
@keyifan520 要去理解思路哈
#include <bits/stdc++.h>
#define ll long long
#define N 1001
#define mod 998244353
#define sortu(a) sort(a.begin(), a.end())
#define uniqueu(a) a.erase(unique(a.begin(), a.end()), a.end())
using namespace std;
mt19937_64 mrand(random_device{}());
const int D[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
char s[N][N];
set<pair<int, int>> st;
inline void solve(void) {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
int x, y, d;
scanf("%d%d%d", &x, &y, &d);
for (int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
st.clear();
st.insert({x, y});
for (int i = 1; i <= k; i++) {
int xx = x + D[d][0], yy = y + D[d][1];
if (xx < 1 || yy < 1 || xx > n || yy > m || s[xx][yy] == 'x') {
d = (d + 1) % 4;
continue;
}
x = xx, y = yy;
st.insert({x, y});
}
printf("%d\n", (int)(st.size()));
}
int main() {
int Test;
scanf("%d", &Test);
for ( ; Test--; ) {
solve();
}
}
by keyifan520 @ 2024-12-08 14:25:27
@Zhi_ptb谢谢,我关注你了
by Zhi_ptb @ 2024-12-08 14:25:56
@keyifan520不用谢
by LionBlaze @ 2024-12-08 14:26:27
惊现蓝名绿勾
by DDD_et @ 2024-12-08 14:27:05
@Zhi_ptb
???set????????要set干嘛
by DDD_et @ 2024-12-08 14:27:43
不用set啊
by LionBlaze @ 2024-12-08 14:28:04
@DDD_et 可以用 set
。
by Zhi_ptb @ 2024-12-08 14:28:37
@DDD_et我没用考场没用set挂了()
by DDD_et @ 2024-12-08 14:29:52
@Zhi_ptb
真不用set,你看我的:(
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N = 1e3 + 10;
bool vis[N][N];
char g[N][N];
int t;
pair <int, int> change (int d)
{
if (d == 0) return {0, 1};
if (d == 1) return {1, 0};
if (d == 2) return {0, -1};
return {-1, 0};
}
int main ()
{
cin >> t;
while (t --)
{
int n, m, k, x, y, d, cnt = 1; cin >> n >> m >> k >> x >> y >> d;
memset (vis, 0, sizeof (vis));
vis[x][y] = true;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++) cin >> g[i][j];
while (k --)
{
auto now = change (d);
int nx = x + now.x;
int ny = y + now.y;
if (nx < 1 || ny < 1 || nx > n || ny > m || g[nx][ny] == 'x')
{
d = (d + 1) % 4;
continue;
}
if (!vis[nx][ny]) cnt ++, vis[nx][ny] = true;
x = nx, y = ny;
}
cout << cnt << '\n';
}
return 0;
}
by Zhi_ptb @ 2024-12-08 14:31:33
@DDD_et哦~学到了