Axolotl_awa @ 2024-11-23 12:18:20
rt,输出比答案算少了
#include <iostream>
#include <cstdio>
#include <set>
#include <string>
#include <cmath>
using namespace std;
int main () {
// freopen ("explore5.in", "r", stdin);
// freopen ("explore5.out", "w", stdout);
int T;
cin >> T;
while (T --) {
int n, m, k, ans = 1;
int x, y, d;
cin >> n >> m >> k >> x >> y >> d;
char a[1002][1002];
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= m; j ++) {
cin >> a[i][j];
}
}
set <int> se;
string s123 = to_string(y);
int nnn = s123.size();
nnn = pow(10, nnn);
se.insert(x * nnn + y);
while (k --) {
// printf ("实际位置:%d %d %d\n", x, y, d);
int x_ = x, y_ = y, d_ = d;
if (d == 0) {
y_ ++;
} else if (d == 1) {
x_ ++;
} else if (d == 2) {
y_ --;
} else {
x_ --;
}
d = d;
// printf ("%d %d %d\n", x_, y_, d_);
if ((x_ >= 1 && x_ <= n) && (y_ >= 1 && y_ <= m) && a[x_][y_] == '.') {
ans ++;
string s12 = to_string(y_);
int nnnn = s12.size();
nnnn = pow(10, nnnn);
se.insert(x_ * nnnn + y_);
// printf ("进入的%d %d %d\n", x_, y_, d_);
x = x_, y = y_;
} else {
d = (d + 1) % 4;
}
}
cout << se.size() << endl;
}
return 0;
}
/*
1
5 5 20
1 1 0
.....
.xxx.
.x.x.
..xx.
x....
*/
by _Eternally_ @ 2024-11-23 12:51:29
@ Axolotl_awa
ans 貌似没啥用
问题在对点的标号上
#include <bits/stdc++.h>
#define int long long
using namespace std;
main () {
// freopen ("explore5.in", "r", stdin);
// freopen ("explore5.out", "w", stdout);
int T;
cin >> T;
while (T --) {
int n, m, k;
int x, y, d;
cin >> n >> m >> k >> x >> y >> d;
char a[1002][1002];
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= m; j ++) {
cin >> a[i][j];
}
}
set <int> se;
// string s123 = to_string(y);
// int nnn = s123.size();
// nnn = pow(10, nnn);
se.insert(m * (x - 1) + y);
while (k --) {
int x_ = x, y_ = y, d_ = d;
if (d == 0) {
y_ ++;
} else if (d == 1) {
x_ ++;
} else if (d == 2) {
y_ --;
} else {
x_ --;
}
if ((x_ >= 1 && x_ <= n) && (y_ >= 1 && y_ <= m) && a[x_][y_] == '.') {
// ans ++;
// string s12 = to_string(y_);
// int nnnn = s12.size();
// nnnn = pow(10, nnnn);
se.insert((x_ - 1) * m + y_);
x = x_, y = y_;
} else {
d = (d + 1) % 4;
}
}
cout << se.size() << endl;
}
return 0;
}
by _Eternally_ @ 2024-11-23 12:56:48
、、、@Axolotl_awa
by Axolotl_awa @ 2024-11-23 13:23:11
@Eternally thxxxxxxxxxxx