QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499514#6723. Grid with ArrowsssmyWA 152ms5840kbC++201.6kb2024-07-31 15:09:572024-07-31 15:10:04

Judging History

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

  • [2024-07-31 15:10:04]
  • 评测
  • 测评结果:WA
  • 用时:152ms
  • 内存:5840kb
  • [2024-07-31 15:09:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int n, m;
const int N = 1e5 + 10;
map <char, int> mt;

void solve()
{
	std:: cin >> n >> m;
	char a[n + 2][m + 2];
	for(int i = 1; i <= n; i ++ )
	{
		for(int j = 1; j <= m; j ++ )
		{
			std:: cin >> a[i][j];
		}
	}

	int b[n + 2][m + 2];
	for(int i = 1; i <= n; i ++ )
	{
		for(int j = 1; j <= m; j ++ )
		{
			std:: cin >> b[i][j];
		}
	}

	bool st[n + 2][m + 2];
	memset(st, 0, sizeof(0));
	for(int i = 1; i <= n; i ++ )
	{
		for(int j = 1; j <= m; j ++ )
		{
			if(!st[i][j])
			{
				int x = i;
				int y = j;
				bool r[n + 2][m + 2];
				memset(r, 0, sizeof(r));
				st[x][y] = true;
				r[x][y] = true;
				while(1)
				{
					int tx = x + dx[mt[a[x][y]]] * b[x][y];
					int ty = y + dy[mt[a[x][y]]] * b[x][y];

					if(tx >= 1 && tx <= n && ty >= 1 && ty <= m && !r[tx][ty])
					{
						st[tx][ty] = true;
						r[tx][ty] = true;
						x = tx;
						y = ty;
					}
					else
					{
						break;
					}					
				}

				bool is = true;
				for(int w = 1; w <= n; w ++ )
				{
					for(int z = 1; z <= m; z ++ )
					{
						if(r[w][z] == false)
						{
							is = false;
						}
					}
				}

				if(is)
				{
					std:: cout << "Yes" << endl;
					return ;
				}
			}
		}
	}

	std:: cout << "No" << endl;
	return ;
}   
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	mt['u'] = 3;
	mt['l'] = 1;
	mt['r'] = 0;
	mt['d'] = 2;
    int T;
    std:: cin >> T;
    while(T -- )
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 152ms
memory: 5840kb

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
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
No
No
Yes
No
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
No
...

result:

wrong answer expected YES, found NO [29th token]