QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#123170 | #6723. Grid with Arrows | lhzawa | WA | 60ms | 13452kb | C++14 | 1.6kb | 2023-07-11 20:29:22 | 2023-07-11 20:29:26 |
Judging History
answer
// lhzawa(https://www.cnblogs.com/lhzawa/)
// Problem: B. Grid with Arrows
// Contest: QOJ - The 2019 ICPC China Shaanxi Provincial Programming Contest
// URL: https://qoj.ac/contest/1285/problem/6723
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> c[N], a[N];
char s[N];
int mp[200];
const int zx[4] = {-1, 1, 0, 0}, zy[4] = {0, 0, -1, 1};
int rd[N];
int main() {
mp['u'] = 0, mp['d'] = 1, mp['l'] = 2, mp['r'] = 3;
function<void ()> solve = []() -> void {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
c[i].clear(), a[i].clear();
}
for (int i = 0; i < n; i++) {
scanf("%s", s);
for (int j = 0; j < m; j++) {
c[i].push_back(mp[(int)(s[j])]);
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x;
scanf("%d", &x);
a[i].push_back(x);
}
}
function<int (int, int)> id = [&m](int x, int y) -> int {
return x * m + y;
};
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
rd[id(i, j)] = 0;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x = i + a[i][j] * zx[c[i][j]], y = j + a[i][j] * zy[c[i][j]];
if (x < 0 || y < 0 || x >= n || y >= m) {
continue;
}
rd[id(x, y)]++;
}
}
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cnt += (rd[id(i, j)] == 0);
}
}
printf("%s\n", cnt <= 1 ? "Yes" : "No");
};
int _;
scanf("%d", &_);
for (; _; _--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 8348kb
input:
2 2 3 rdd url 2 1 1 1 1 2 2 2 rr rr 1 1 1 1
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #2:
score: -100
Wrong Answer
time: 60ms
memory: 13452kb
input:
1109 5 8 rddddldl drruludl rrldrurd urrrlluu uurrulrl 4 4 1 2 4 3 1 6 1 3 5 1 1 1 3 6 2 4 1 1 2 1 1 1 2 3 4 2 4 3 3 3 4 1 1 2 2 5 1 5 7 9 rdrddrdll urrdruldl ruullrulu drrlrlddl rrrdddlll ruulururl ruurrlluu 7 1 1 1 2 1 2 3 6 1 7 3 1 3 1 2 1 8 2 2 1 2 4 3 1 2 2 2 2 4 1 1 5 3 3 1 3 4 6 1 2 1 2 7 7 6 ...
output:
Yes Yes No No Yes No Yes Yes Yes Yes No Yes No Yes Yes No Yes No Yes No No No Yes Yes Yes Yes Yes No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes No Yes Yes No No Yes Yes Yes Yes Y...
result:
wrong answer expected NO, found YES [2nd token]