QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382580#3742. 卖萌表情ucup-team1251RE 0ms0kbC++201.9kb2024-04-08 16:34:162024-04-08 16:34:18

Judging History

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

  • [2024-04-08 16:34:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-08 16:34:16]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

string mp[1007];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	while (cin >> n >> m)
	{
		for (int i = 1; i <= n; i++)
		{
			cin >> mp[i];
			mp[i] = " " + mp[i];
		}
		vector<vector<bool>> st(n + 1, vector<bool>(m + 1, 0));
		long long cnt = 0;
		for (int j = 1; j <= m; j++)
		{
			for (int i = 1; i <= n; i++)
			{
				if (st[i][j]) continue;
				if (mp[i][j] == '^')
				{
					int x1 = i + 1, y1 = j - 1, x2 = i + 1, y2 = j + 1;
					if (x1 <= n && y1 >= 1 && x2 <= n && y2 <= m)
					{
						if (!st[x1][y1] && !st[x2][y2] && mp[x1][y1] == 'v' && mp[x2][y2] == 'v')
						{
							cnt++;
							st[i][j] = true, st[x1][y1] = st[x2][y2] = true;
						}
					}
				}
				else if (mp[i][j] == 'v')
				{
//					cout << i << " " << j << endl;
					int x1 = i - 1, y1 = j - 1, x2 = i - 1, y2 = j + 1;
					if (x1 >= 1 && y1 >= 1 && x2 >= 1 && y2 <= m)
					{
						if (!st[x1][y1] && !st[x2][y2] && mp[x1][y1] == '^' && mp[x2][y2] == '^')
						{
							cnt++;
							st[i][j] = true, st[x1][y1] = st[x2][y2] = true;
						}
					}
				}
			}
		}
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
			{
				if (st[i][j]) continue;
				if (mp[i][j] == '<')
				{
					int x1 = i - 1, y1 = j + 1, x2 = i + 1, y2 = j + 1;
					if (x1 >= 1 && y1 <= m && x2 <= n && y2 <= m)
					{
						if (!st[x1][y1] && !st[x2][y2] && mp[x1][y1] == '>' && mp[x2][y2] == '>')
						{
							cnt++;
							st[i][j] = true, st[x1][y1] = st[x2][y2] = true;
						}
					}
				}
				else if (mp[j][i] == '>')
				{
					int x1 = i - 1, y1 = j - 1, x2 = i + 1, y2 = j - 1;
					if (x1 >= 1 && y1 >= 1 && x2 <= n && y2 >= 1)
					{
						if (!st[x1][y1] && !st[x2][y2] && mp[x1][y1] == '<' && mp[x2][y2] == '<')
						{
							cnt++;
							st[j][i] = true, st[x1][y1] = st[x2][y2] = true;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

3 10
^>^<^^^^>^
<v^v^^v^v>
<>vvvvvvvv
10 1
v
^
<
<
v
<
v
>
<
<
5 4
<^^^
<vvv
<<^>
vv^v
<vvv
2 9
^^^^^^^^^
vvvvvvvvv
9 10
^>^^<^<^<>
<^<<><<<<>
v^v^^<>^<^
^<vvv<><<>
<v>>><^v^>
^^^^>^^<<v
v^v>v^v^<>
v^vvv>v^<^
vvvvv><>v>
8 8
^^^^<^<^
<>^<v>v^
<v<v>^v>
v>v<vv<>
^<^>>v<>
<v^v^<<>
^v^^>v<>
<vv<vv<>
2 2
...

output:

5
0
4
6
11
9
0
3
7
6
9
0
5
2
0
5
0
4
2
0
0
0
0
2
4
6
3
5
4
8
2
0
4
6
5
3
0
5
0
16
6
2
6
2
4
4
8
4
7
0
0
9
0
3
4
6
4
10

result: