QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499671#6723. Grid with ArrowsziripoWA 0ms3732kbC++201.3kb2024-07-31 16:50:502024-07-31 16:50:51

Judging History

你现在查看的是最新测评结果

  • [2024-07-31 16:50:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2024-07-31 16:50:50]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;

vector<vector<char>> x;
vector<vector<ll>> f;

int main() {
	ll t; cin >> t;
	for (ll i = 0; i < t; i++) {
		ll n, m; scanf("%lld%lld", &n, &m);
		vector<vector<char>> x(n, vector<char>(m));
		vector<vector<ll>> s(n, vector<ll>(m));
		vector<vector<ll>> f(n, vector<ll>(m, 0));
		ll t = 0, xt = 0, yt = 0;
		for (ll i = 0; i < n; i++)for (ll j = 0; j < m; j++)cin >> x[i][j];
		for (ll i = 0; i < n; i++)for (ll j = 0; j < m; j++)cin >> s[i][j];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (f[i][j] != 0)
					continue;
				t++;
				ll p = i, q = j;
				f[p][q] = -1;
				int c = i * n + j + 1;
				while (p >= 0 && p < n && q >= 0 && q < m) {
					if (x[p][q] == 'u')
						p -= s[p][q];
					else if (x[p][q] == 'd')
						p += s[p][q];
					else if (x[p][q] == 'r')
						q += s[p][q];
					else if (x[p][q] == 'l')
						q -= s[p][q];
					if (!(p >= 0 && p < n && q >= 0 && q < m))
						break;
					if (f[p][q] == c)
						break;
					if (f[p][q] == -1) {
						if (p == i && q == j)
							break;
						f[p][q] = c;
						t--;
						break;
					}
					f[p][q] = c;
				}
			}
		}
		cout << t << "\n";
		if (t <= 1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3732kb

input:

2
2 3
rdd
url
2 1 1
1 1 2
2 2
rr
rr
1 1
1 1

output:

1
Yes
2
No

result:

wrong output format YES or NO expected, but 1 found [1st token]