QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384157#3742. 卖萌表情rukongAC ✓132ms5620kbC++171.4kb2024-04-09 20:54:282024-04-09 20:54:28

Judging History

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

  • [2024-04-09 20:54:28]
  • 评测
  • 测评结果:AC
  • 用时:132ms
  • 内存:5620kb
  • [2024-04-09 20:54:28]
  • 提交

answer

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
const int N=1010;
int n,m;
char c[N][N];
bool bi[N][N];//标记当前位置有没有被用过
int cnt;
signed main()
{
	while(cin>>n>>m)
	{
		cnt=0;
		memset(bi,0,sizeof bi);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				cin>>c[i][j];
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
			{
				if(!bi[i][j])
				{
					if(c[i][j]=='^')
					{
						if((i+1)<n&&(j-1)>=0&&(j+1)<m&&c[i+1][j-1]=='v'&&c[i+1][j+1]=='v'&&!bi[i+1][j-1]&&!bi[i+1][j+1])
						{
							cnt++;
							bi[i+1][j-1]=1;
							bi[i+1][j+1]=1;
							bi[i][j]=1;
						}

						else if((i+1)<n&&(j+2)<m&&c[i][j+2]=='^'&&c[i+1][j+1]=='v'&&!bi[i][j+2]&&!bi[i+1][j+1])
						{
							bi[i][j+2]=1;
							bi[i+1][j+1]=1;
							bi[i][j]=1;
							cnt++;
						}
					}
					else if(c[i][j]=='>'){
						if((i-1)>=0&&(j-1)>=0&&(i+1)<n&&c[i-1][j-1]=='<'&&c[i+1][j-1]=='<'&&!bi[i-1][j-1]&&!bi[i+1][j-1]){
							bi[i][j]=1;
							bi[i-1][j-1]=1;
							bi[i+1][j-1]=1;
							cnt++;
						}
					}
					else if(c[i][j]=='<')
					{
						if((i-1)>=0&&(i+1)<n&&(j+1)<m&&c[i-1][j+1]=='>'&&c[i+1][j+1]=='>'&&!bi[i-1][j+1]&&!bi[i+1][j+1])
						{
							bi[i][j]=1;
							bi[i-1][j+1]=1;
							bi[i+1][j+1]=1;
							cnt++;
						}
					}
				}
			}
		}
		
		cout<<cnt<<endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 132ms
memory: 5620kb

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
13
10
0
3
7
7
10
0
6
2
0
5
0
4
3
0
0
0
0
4
5
6
3
5
4
9
2
0
4
6
6
4
0
5
0
16
6
2
6
2
5
4
10
4
8
0
0
10
0
4
5
6
4
12
12
2
0
13
4
4
6
6
5
0
5
0
6
6
2
11
0
11
5
0
2
0
0
11
18
5
2
6
14
8
7
4
0
0
0
7
8
3
6
0
0
13
6
2
9
5
4
13
7
9
0
3
14
0
6
0
5
14
9
5
4
0
0
3
2
9
6
17
6
4
12
0
0
8
5
12
0
5
9
4
2
0...

result:

ok 5051 numbers