QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841884#9965. Game MPOucup-team1004#AC ✓1ms4244kbC++141.3kb2025-01-04 08:36:152025-01-04 08:36:16

Judging History

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

  • [2025-01-04 08:36:16]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4244kb
  • [2025-01-04 08:36:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool ok(char a){return a>='A'&&a<='Z';}
bool okok(char a)
{
	return (a>='a'&&a<='z')||(a>='A'&&a<='Z');
}
bool chk(char a,char b)
{
	if(!okok(a)||!okok(b)) return 0;
	if(a>'a'&&a<'z') a=a-'a'+'A';
	if(b>'a'&&b<'z') b=b-'a'+'A';
	return (a=='O'&&b=='O')||(a=='P'&&b=='M')||(a=='M'&&b=='P');
}
const int N=110;
int n,vis[N][N];
char t[N][N];
vector<pair<int,int>> to[N][N];
void dfs(int x,int y)
{
	vis[x][y]=1;
	if(t[x][y]>'a'&&t[x][y]<'z') t[x][y]=t[x][y]-'a'+'A';
	for(auto k:to[x][y])
	{
		int X=x+k.first,Y=y+k.second;
		if(!vis[X][Y]) dfs(X,Y);
	}
}
int calc()
{
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(!ok(t[i][j])) continue;
			ans+=2;
			for(auto k:to[i][j])
				if(ok(t[i+k.first][j+k.second])) ans++;
		}
	return ans/2;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%s",t[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int p=-1;p<=1;p++)
				for(int q=-1;q<=1;q++)
					if(!(p==0&&q==0)&&chk(t[i][j],t[i+p][j+q]))
						to[i][j].push_back({p,q});
	printf("%d ",calc());
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!vis[i][j]&&t[i][j]>='A'&&t[i][j]<='Z') dfs(i,j);
	printf("%d\n",calc());
	for(int i=1;i<=n;i++) puts(t[i]+1);
}

详细

Test #1:

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

input:

4
.pm.
Mom.
OOm.
p..p

output:

4 13
.PM.
MOM.
OOm.
p..p

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 4240kb

input:

2
.P
P.

output:

2 2
.P
P.

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 4236kb

input:

3
...
.pp
.m.

output:

0 0
...
.pp
.m.

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 4172kb

input:

4
....
....
....
....

output:

0 0
....
....
....
....

result:

ok 5 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

5
m....
m.Mop
OOpoo
PMp..
Oo...

output:

8 15
m....
m.Mop
OOPoo
PMP..
OO...

result:

ok 6 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 4200kb

input:

6
Mo..Op
..P.p.
p.MopP
mMpO.P
..mp.p
OM.Mo.

output:

12 26
Mo..Op
..P.p.
P.MOpP
MMPO.P
..MP.p
OM.Mo.

result:

ok 7 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 4108kb

input:

7
.M.O.M.
.PM...M
MO.MMP.
O.O.P.P
POOOOM.
MO...MP
..MOP.O

output:

53 53
.M.O.M.
.PM...M
MO.MMP.
O.O.P.P
POOOOM.
MO...MP
..MOP.O

result:

ok 8 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 4056kb

input:

8
m.mm..p.
.oo.op.p
.op.pm..
...p.pmp
.o.ooo..
m.momo.o
omp.pmmo
mp.mmo..

output:

0 0
m.mm..p.
.oo.op.p
.op.pm..
...p.pmp
.o.ooo..
m.momo.o
omp.pmmo
mp.mmo..

result:

ok 9 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 4200kb

input:

9
pp...p.pP
...PmOM.o
.MOM.M.Mm
O.op.pppP
Oo..opMp.
.pPM..p.p
.m.M.o.m.
pPP.PO.O.
mopMooom.

output:

31 93
pp...P.PP
...PMOM.o
.MOM.M.MM
O.OP.PPPP
OO..oPMP.
.PPM..P.P
.M.M.O.M.
PPP.PO.O.
MoPMOOOm.

result:

ok 10 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 4200kb

input:

10
M.oMppo..p
Pp...pmMp.
o..mp.P.m.
OMm..M..M.
OPPmM.o.M.
.pO..mOm.p
O..o..P.m.
.m..OOp.m.
p..Oomm...
.p.oMpmmp.

output:

30 86
M.oMPPo..p
PP...PMMP.
O..MP.P.M.
OMM..M..M.
OPPMM.O.M.
.pO..MOM.P
O..O..P.M.
.m..OOP.m.
p..OOMM...
.p.OMPMmp.

result:

ok 11 lines

Test #11:

score: 0
Accepted
time: 0ms
memory: 4244kb

input:

10
P.o.OoP...
Mpm.PmPpMm
p.....O..M
MpOM..Ompp
.m.Oo.pM.P
....mOmmPo
Ppoo.mm...
..OM.o.P.p
OPO....M.P
P.ooo.mP.p

output:

36 89
P.o.OOP...
MPM.PMPPMm
P.....O..M
MPOM..OMPP
.M.OO.PM.P
....mOMMPo
PpOO.mM...
..OM.o.P.p
OPO....M.P
P.OOO.MP.p

result:

ok 11 lines

Test #12:

score: 0
Accepted
time: 0ms
memory: 4184kb

input:

10
.m..Oooomo
..........
MOMoomp.Pp
..........
mMP..omOoM
.........O
mmOmoOm.PM
m.........
PmM.O.Mpp.
.........o

output:

20 37
.m..OOOOmo
..........
MOMoomp.Pp
..........
mMP..omOOM
.........O
mmOmOOm.PM
M.........
PMM.O.MPp.
.........o

result:

ok 11 lines

Test #13:

score: 0
Accepted
time: 0ms
memory: 4188kb

input:

10
Oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo
oooooooooo

output:

1 442
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO
OOOOOOOOOO

result:

ok 11 lines

Test #14:

score: 0
Accepted
time: 1ms
memory: 4132kb

input:

10
Oooooooooo
.........o
oooooooooo
o.........
oooooooooo
.........o
oooooooooo
o.........
oooooooooo
.........o

output:

1 118
OOOOOOOOOO
.........O
OOOOOOOOOO
O.........
OOOOOOOOOO
.........O
OOOOOOOOOO
O.........
OOOOOOOOOO
.........O

result:

ok 11 lines

Test #15:

score: 0
Accepted
time: 1ms
memory: 4196kb

input:

10
Mm.Op.OM.m
oP.o..mO.m
..........
pm....oo.P
pm.mp..O.o
..........
.p.m.....M
Mm.M..pM.o
..........
OP.Mp.oP.P

output:

19 36
MM.Op.OM.m
oP.O..mO.m
..........
pm....OO.P
pm.mp..O.o
..........
.P.m.....M
MM.M..PM.o
..........
OP.MP.oP.P

result:

ok 11 lines

Test #16:

score: 0
Accepted
time: 1ms
memory: 4204kb

input:

10
mpm.mpmpmp
pmpmpm..pm
mpmpm.mpmp
.mpmpmpmpm
mpmpmpmpm.
pmpm..p.p.
mpmpmpmpmp
..pmpmpm.m
mpmpmpmpmp
pmpmpmpmpM

output:

1 224
MPM.MPMPMP
PMPMPM..PM
MPMPM.MPMP
.MPMPMPMPM
MPMPMPMPM.
PMPM..P.P.
MPMPMPMPMP
..PMPMPM.M
MPMPMPMPMP
PMPMPMPMPM

result:

ok 11 lines

Test #17:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

10
OM.op.MO.o
po.MO.op.O
..........
OP.om.po.O
mO.Po.OM.o
..........
PO.mo.pp.P
Om.oP.mm.m
........O.
Oo.oO.Mp.o

output:

25 63
OM.OP.MO.O
PO.MO.OP.O
..........
OP.oM.PO.O
MO.Po.OM.O
..........
PO.Mo.pp.P
OM.oP.mm.M
........O.
OO.OO.MP.O

result:

ok 11 lines

Extra Test:

score: 0
Extra Test Passed