QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865300#8118. PahuljiceUnforgettablepl#50 ✓1ms3712kbC++201.6kb2025-01-21 16:33:592025-01-21 16:34:08

Judging History

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

  • [2025-01-21 16:34:08]
  • 评测
  • 测评结果:50
  • 用时:1ms
  • 内存:3712kb
  • [2025-01-21 16:33:59]
  • 提交

answer

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

#define int long long


int32_t main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector grid(n+1,vector<char>(m+1));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> grid[i][j];
		}
	}
	int ma = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(grid[i][j]!='+')continue;
			int ans = n;
			{
				// right
				int t = 0;
				for(int x=j+1;x<=m;x++){
					if(grid[i][x]!='-')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left
				int t = 0;
				for(int x=j-1;x;x--){
					if(grid[i][x]!='-')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// down
				int t = 0;
				for(int x=i+1;x<=n;x++){
					if(grid[x][j]!='|')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// up
				int t = 0;
				for(int x=i-1;x;x--){
					if(grid[x][j]!='|')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// right-down
				int t = 0;
				for(int x=1;i+x<=n and j+x<=m;x++){
					if(grid[i+x][j+x]!='\\')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left-up
				int t = 0;
				for(int x=1;i-x>0 and j-x>0;x++){
					if(grid[i-x][j-x]!='\\')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left-down
				int t = 0;
				for(int x=1;i+x<=n and j-x>0;x++){
					if(grid[i+x][j-x]!='/')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// right-up
				int t = 0;
				for(int x=1;i-x>0 and j+x<=m;x++){
					if(grid[i-x][j+x]!='/')break;
					t++;
				}
				ans = min(ans,t);
			}
			ma = max(ma,ans);
		}
	}
	cout << ma << '\n';
}

詳細信息

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

10 10
.\|/......
.-+-\|/...
./|\-+-...
..\|/|\...
..-+-.....
../|\\|/..
.....-+-..
...../|\..
..........
..........

output:

1

result:

ok single line: '1'

Test #2:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

20 20
......\|/...........
......-+-...........
....../|\.......\|/.
........\|/.\|/.-+-.
........-+-.-+-./|\.
\|/...../|\./|\.\|/.
-+-...\|/.\|/...-+-.
/|\...-+-.-+-.../|\.
...\|//|\./|\.......
...-+-..............
.../|\..............
..........\|/.......
.......\|/-+-.......
.......-+-/|\..\|/..
...

output:

1

result:

ok single line: '1'

Test #3:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

50 50
......\|/.....................................\|/.
......-+-.\|/.................................-+-.
....../|\.-+-.........\|/.\|/.\|/..........\|//|\.
........../|\|/.......-+-.-+-.-+-..\|/.....-+-\|/.
............-+-\|/..\|/|\./|\./|\|/-+-\|/../|\-+-.
........\|/./|\-+-..-+-...\|/...-+-/|\-...

output:

1

result:

ok single line: '1'

Test #4:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

50 50
...................\|/............................
...................-+-.........\|/................
.......\|/........./|\.........-+-...........\|/..
.......-+-...................../|\...........-+-..
.\|/.../|\....\|/............\|/..\|/......../|\..
.-+-..........-+-\|/.........-+-..-+-.\...

output:

1

result:

ok single line: '1'

Test #5:

score: 11
Accepted
time: 0ms
memory: 3584kb

input:

10 10
..+..\/..-
/.--|\+..+
/..--++.|.
|.-+.-....
...+....+.
.\.\/..+|-
+.|\|..++.
..\\|\\|..
.-.-\|-/..
+\//.+--.\

output:

0

result:

ok single line: '0'

Test #6:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

20 20
../.||..+.\|+/..\\\\
|++.+./....\\/..++..
..+/...+|//+.|/.\|.\
\|..|..\.\+\..|-.\.-
|\.+-\.....-..|..+.|
.\-+...+///+.|.....+
\-/\...-..../.|/+.+.
-.....++|/+..-...\-\
-+..+...\-..++.+-../
//+.+.++.-|//../+.\|
.|...\..../../+.|+-.
\/---\..-|/\/......\
|||./+-./.|.\\|./|--
./|.\....\+...\/..+|
...

output:

0

result:

ok single line: '0'

Test #7:

score: 11
Accepted
time: 0ms
memory: 3584kb

input:

50 50
|\/.+/.+../....-+\..../+/../-/.|-./...\..+-\+.|.|+
\.-.-..../..|-......|-\..+.\..|.\...-/..-..\-|.|/-
./\..+/.-++/\-+./\+.\.-|+.....++.|-....\./|..-\--.
.\./.|.../../..|./.../\.+..+\.../......-|-.//...|+
\../.+-../.../.|..|../+......//./.-+\+.\/-|\++/+..
../.\...\\..|..\.-/.-|\.+||.|../\\\..+....

output:

0

result:

ok single line: '0'

Test #8:

score: 11
Accepted
time: 0ms
memory: 3712kb

input:

50 50
.....\.++...+.....+./.-..-....|..\--....+.+..\.../
|+.+-.|..++|...+|.++.|.../..+.|.+...\\.-+..+./\-/-
.....\-.\/-\/\-/.-/...\++...+\|\.\...//.-|\....\\/
...-.../+/.|\\.\+..-//../..|--..\+.++\.+|..|+|\../
./+.-\-+..||\..|-/....-.|\/-./\\-+.|..|/\-../...-+
--|.|-||\-.....\..-|-../\...+-|.\-+\..\...

output:

0

result:

ok single line: '0'

Subtask #2:

score: 11
Accepted

Test #9:

score: 11
Accepted
time: 1ms
memory: 3712kb

input:

5 5
.|../
.|./.
\|/..
-+---
/|\..

output:

1

result:

ok single line: '1'

Test #10:

score: 11
Accepted
time: 1ms
memory: 3712kb

input:

10 10
.\/|.//...
./-|..../.
---+------
.\/|\.....
././.\..\.
/..|..\...
...|...\\.
...|....\.
...|.--\/\
...|..\...

output:

0

result:

ok single line: '0'

Test #11:

score: 11
Accepted
time: 1ms
memory: 3584kb

input:

20 20
/.......././.\....|.
......../.....\...|.
...............\..|.
................\.|.
../..............\|/
\-----------------+-
......./.\......./|\
..................|.
.............../..|.
............./....|.
............./....|.
............/...../.
.........../......|.
.......././.......|.
...

output:

1

result:

ok single line: '1'

Test #12:

score: 11
Accepted
time: 1ms
memory: 3584kb

input:

20 20
...............|....
\..............|....
.\.............|....
|.\............|....
.-.\..\........|....
....\..........|....
.....\.........|....
......\...|....|.-..
.......\.......|.|..
....-...\......|....
.....-...\.....|....
..........\....|....
|..........\...|.../
............\..|../.
...

output:

0

result:

ok single line: '0'

Test #13:

score: 11
Accepted
time: 1ms
memory: 3712kb

input:

50 50
.....-\............/....|...........\......|......
/........./...-.|\..\..-.............\.../.|...../
.../...-\.....-/..-........../|......./....|..../.
.....\...|......./................/....\...|..//.\
.................|.........././...|.....\/.|../...
.......\.........\.../........\....\./\...

output:

2

result:

ok single line: '2'

Test #14:

score: 11
Accepted
time: 0ms
memory: 3584kb

input:

50 50
-........./....../......||........../.............
../\....//.-.......|.....|........................
..-..../.................|..........-.........-...
.................../.\...|...../............/....-
..|.|....\-..../...|....-||.......-...-......\./..
...-././.....-....\..-...|./..............

output:

3

result:

ok single line: '3'

Test #15:

score: 11
Accepted
time: 1ms
memory: 3712kb

input:

50 50
..............\.\.......\.\........./....|........
.........................\...............|........
...............\..........\..............|../.....
.............\.............\..........\../........
..\.........................\\...........|........
...........\...\.............\.....\......

output:

7

result:

ok single line: '7'

Subtask #3:

score: 28
Accepted

Test #16:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

5 5
.|./\
\|/..
-+---
/|\..
.|.\/

output:

1

result:

ok single line: '1'

Test #17:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

10 10
......\|/.
.\.|./-+-.
..\|/./|\.
.--+--....
.\/|\/....
./\|/\....
.--+--....
../|\.\|/.
./.|.\-+-.
....../|\.

output:

2

result:

ok single line: '2'

Test #18:

score: 28
Accepted
time: 1ms
memory: 3712kb

input:

20 20
.\|/\|/\|/..\.|./...
.-+--+--+--..\|/....
./|\/|\/|\.---+---..
\.|././\|/\../|\....
.\|/...-+-../.|.\...
--+--../|\|/..|..\..
./|\.....-+-........
/.|.\..../|\.\..|../
....\..|../...\.|./.
.....\.|./.....\|/..
\|/...\|/.\|/---+---
-+-.---+---+-../|\..
/|\/../|\./|\./.|.\\
\|/../.|.\.../..|..\
...

output:

3

result:

ok single line: '3'

Test #19:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

30 30
.\.|./....\|/.\|/\|/\|/.......
..\|/.....-+-.-+--+--+-.\|/...
---+------/|\\/|\/|\/|\.-+----
../|\..\|/....\|/...\.|./|\...
./.|.\.-+-\|/--+--...\|/......
/..|..\/|\-+-./|\...--+--.....
...|...\\./|\/.||\|/./|\/..../
.|.|.../\\......|-+-/.|/\\../.
.|.|../..\\.....|/|\../...\/..
.|.../..\.|\/.....

output:

8

result:

ok single line: '8'

Test #20:

score: 28
Accepted
time: 1ms
memory: 3584kb

input:

40 40
...\..|../..\|/...\|/...\|/.............
....\.|./...-+-..--+--.--+--....\|/..\|/
.....\|/..../|\..\/|\/../|\.....-+-..-+-
...---+---....\|//\|/\./.|\\.|../|\../|\
..|../|\..|...-+---+--..../\.|./..\....\
\.|./.|.\.|.../|\./|\..../..\|/....\....
.\|/..|..\|\|/.../\|/\../.---+---\|/\...
--+---....

output:

10

result:

ok single line: '10'

Test #21:

score: 28
Accepted
time: 1ms
memory: 3584kb

input:

50 50
\|/..\|/...\|/......\.......|\.|./.\/.|../.....\|/
-+----+---.-+-\.|./..\...\|/|.\|/../\.|./\.|./.-+-
/|\../|\.../|\.\|/....\..-+-|--+--/..\|/..\|/../|\
..../.|.\.|./.--+--.\.|\//|\|./|\/----+----+--....
.../.\|/.\|/.../|\...\|/\...|/.|/\.../|\../|\.....
.|./.-+---+--./\|/\.--+--\..|../..../.|...

output:

8

result:

ok single line: '8'

Test #22:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

50 50
.\.|./...\.|./..\...\|/|....../........\.|./......
..\|/\.|./\|/....\..-+-|\|/../...\.|./..\|/.......
.--+--\|/--+--.\|/\./|\|-+-./.....\|/----+----\|/.
../|\--+--/|\..-+-.\...|/|\/.\|/.--+--../|\...-+-.
./\|/\/|\/\|/\./|\|/\..|../..-+-../|\../.|.\../|\.
..-+-/.|.\-+-....-+-.\.|./.../|\./.|.\/...

output:

7

result:

ok single line: '7'

Test #23:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

50 50
...\|/......\|/..\....|..../...\|/...\|/..\|/\|/..
...-+-\|/.---+---.\...|.../.\|/-+-...-+-.--+--+--.
.\|/|\-+-.../|\....\..|../..-+-/|\|/./|\../|\/|\..
.-+-../|\../.|.\....\.|./.../|\..-+-...../.|/\|.\.
./|\....../..|..\....\|/........./|\........\|/...
..--------------------+----------------...

output:

8

result:

ok single line: '8'

Test #24:

score: 28
Accepted
time: 1ms
memory: 3712kb

input:

50 50
........\|/\|/.\|/.\|/|.\|/....\.|./....\|/../...\
\...\|/--+--+---+-.-+-|.-+-.....\|/\|/.--+--/..\|/
.\..-+-./|\/|\./|\./|\|./|\....--+--+-../|\/...-+-
.|\./|\/.|/\||\/......|\...|...//|\/|\|/.|/\.\./|\
.|.\../.....\|/.\|/\|/|.\..|..//.|.\.-+-./....\...
.|..\/.\|/.--+---+--+-|..\.|./\.|./../|...

output:

22

result:

ok single line: '22'

Test #25:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

50 50
.|-./..|++/+|./-./\\\+.-..\-..|\/..//|/-..../.-.\+
/++....+-+...-|\-.-|+..\+...\\.../\../\-|.\-.+....
-.|.--|../--|.....--|.../\/.|-/-/./.-/+|./..-.+..\
|+.\../-|.--/+|..-/.|..-/+-\.-\.../\.\+.\../+-...-
|+.+...|+....\++..+/...+|...||+..\.|..\|../.\\--..
./.\.-\.-\+/-.|.++..-.\/-+|.|.-++..////...

output:

0

result:

ok single line: '0'

Test #26:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

50 50
+/+|.-/||.+|+-/+./../|.-/\|.+\\...+\\/.++//.-.\+|/
|....../...+/..|./-/-\||++-.\+.-|.\+|/-+\.\.-//\+\
\|..//|//.|.-..|\/.\..\||/\.\|+/-+-....+..|....\.-
++.\.|.+.\/.\+||/...\+./\..\.||.|.|..|||+\.-\|++..
+\..|.-....-/..-\++.-..|\|./.-\.+.-.|..+.--..\|\.\
./..../|..|-|+.|+|.++|...+||/|\/|.-..+....

output:

0

result:

ok single line: '0'

Test #27:

score: 28
Accepted
time: 0ms
memory: 3712kb

input:

50 50
||.+|+-..\+.\|\/-|....-|//+/|///\\\\|.-.-../.+\--.
+/+./||+-\....\.\|.-.||-../...\..././\/.+-+..//.|\
.\.\+-+--\...\.//.|//.\+.-//.+/+./-/.+|./.-...../-
|+\|.....+-.-....+-..\..-../\..|\--.\++....-/./+\/
./|\/-....|/\+-|\-.|--./+/|+-.-.+.+-..+\|..-..++|.
.+-..|..+.|+\..\|/-|-+/.+..|-/.|+\|+\/\...

output:

0

result:

ok single line: '0'

Extra Test:

score: 0
Extra Test Passed