QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641407#48. Paint buckettest12350 ✓12ms13480kbC++141.2kb2024-10-14 20:23:352024-10-14 20:23:36

Judging History

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

  • [2024-10-14 20:23:36]
  • 评测
  • 测评结果:50
  • 用时:12ms
  • 内存:13480kb
  • [2024-10-14 20:23:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
const int a[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int read(){
	int ret=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
	return ret*f;
}
int n,m,x,y,c;
char ch[maxn][maxn];
bool vis[maxn][maxn];
struct node{
	int x,y;	
}que[maxn*maxn];
bool check(int x,int y){
	return 1<=x&&x<=n&&1<=y&&y<=m&&!vis[x][y];
}
void BFS(){
	int hed=0,til=0;
	char p=ch[x][y];
	que[++til]=(node){x,y};
	vis[x][y]=1;
	ch[x][y]=c+'0';
	while(hed<til){
		node now=que[++hed];
		for(int i=0;i< 4;++i){
			if(check(now.x+a[i][0],now.y+a[i][1])&&ch[now.x+a[i][0]][now.y+a[i][1]]==p){
				que[++til]=(node){now.x+a[i][0],now.y+a[i][1]};
				vis[now.x+a[i][0]][now.y+a[i][1]]=1;
				ch[now.x+a[i][0]][now.y+a[i][1]]=c+'0';
			}
		}
	}
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			ch[i][j]=getchar();
			while(!isdigit(ch[i][j])) ch[i][j]=getchar(); 
		}
	}
	x=read()+1,y=read()+1;
	c=read();
	BFS();
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			putchar(ch[i][j]);
		}
		putchar('\n');
	}	
	return 0;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 2.5
Accepted
time: 1ms
memory: 5680kb

input:

1 1
0
0 0 2

output:

2

result:

ok single line: '2'

Test #2:

score: 2.5
Accepted
time: 1ms
memory: 5664kb

input:

1 999
010000122000221212000001102122211002021202201110221220121222121222002201000022112022221100201011120001120222011111202102200122021122000201102120112000111220210100222022001010222211100202002001000000010122201010210200200201200111011010021221202001002001022101101221110120110102112120122201100102...

output:

010000122000221212000001102122211002021202201110221220121222121222002201000022112022221100201011120001120222011111202102200122021122000201102120112000111220210100222022001010222211100202002001000000010122201010210200200201200111011010021221202001002001022101101221110120110102112120122208800102122012...

result:

ok single line: '010000122000221212000001102122...0110012111220002220211210211021'

Test #3:

score: 2.5
Accepted
time: 12ms
memory: 13480kb

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 999 lines

Test #4:

score: 2.5
Accepted
time: 7ms
memory: 7152kb

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #5:

score: 2.5
Accepted
time: 8ms
memory: 9328kb

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #6:

score: 2.5
Accepted
time: 1ms
memory: 5748kb

input:

100 100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
333333333333333333333333333333333333333333333333333333333333333333333333333333333333300000...

output:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
77777777777777777777777777777777777777777777777777777777777777777777777777777777777770000000000000...

result:

ok 100 lines

Test #7:

score: 2.5
Accepted
time: 1ms
memory: 5664kb

input:

10 10
0000000000
0000000000
0000000000
0002222222
0002222222
0002222222
0002222222
0002222222
0002222222
0000000000
4 3 8

output:

0000000000
0000000000
0000000000
0008888888
0008888888
0008888888
0008888888
0008888888
0008888888
0000000000

result:

ok 10 lines

Test #8:

score: 2.5
Accepted
time: 1ms
memory: 5696kb

input:

37 41
00000000000000000000000000000000000000000
00003333332222222000000000000000000000000
00003333332222222400000000000000000000000
00003333332222222400000000000000000000000
00000000002222222000000000000000000000000
01111000002222222000000000000000000000000
01111000002222222000000000000000000000000
...

output:

99999999999999999999999999999999999999999
99993333332222222999999999999999999999999
99993333332222222499999999999999999999999
99993333332222222499999999999999999999999
99999999992222222999999999999999999999999
91111999992222222999999999999999999999999
91111999992222222999999999999999999999999
911119...

result:

ok 37 lines

Test #9:

score: 2.5
Accepted
time: 1ms
memory: 5732kb

input:

101 23
00000000000000000000000
00000000000000000000000
00000000000000000000000
00550000000000000000000
00550000000000000000000
00550000000000666666666
00000000000000666666666
00000000000033666666666
00000000000033666666666
00000000000033666666666
00000000000033666666666
00000000000033666666666
00000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00550000000000000000000
00550000000000000000000
00550000000000777777777
00000000000000777777777
00000000000033777777777
00000000000033777777777
00000000000033777777777
00000000000033777777777
00000000000033777777777
000000000000...

result:

ok 101 lines

Test #10:

score: 2.5
Accepted
time: 1ms
memory: 5720kb

input:

99 99
000111111111111111111110000000222222222200000000000002222222222111111111111111111111111111110000000
000111111111111111111100000000222222222200000000000002222222222222222222211111111111111111110000000
0000000000000000000000000000000000000000000000000000022222222222222222222000000000000000000000...

output:

000111111111111111111110000000222222222200000000000002222222222111111111111111111111111111110000000
000111111111111111111100000000222222222200000000000002222222222222222222211111111111111111110000000
000000000000000000000000000000000000000000000000000002222222222222222222200000000000000000000000000
...

result:

ok 99 lines

Test #11:

score: 2.5
Accepted
time: 6ms
memory: 9368kb

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #12:

score: 2.5
Accepted
time: 1ms
memory: 5720kb

input:

2 2
00
00
0 0 5

output:

55
55

result:

ok 2 lines

Test #13:

score: 2.5
Accepted
time: 1ms
memory: 5608kb

input:

10 10
0020000000
0020000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
7 0 5

output:

5525555555
5525555555
5555555555
5555555555
5555555555
5555555555
5555555555
5555555555
5555555555
5555555555

result:

ok 10 lines

Test #14:

score: 2.5
Accepted
time: 0ms
memory: 5736kb

input:

10 10
1011010001
1101110010
1011100101
0001000100
0111011101
1001000011
0010010001
1100011010
1111100001
1001100101
8 3 7

output:

1011010001
1101110010
1011100101
0001000100
0111011101
1001000011
0010010001
7700011010
7777700001
7007700101

result:

ok 10 lines

Test #15:

score: 2.5
Accepted
time: 0ms
memory: 5552kb

input:

21 65
53873158858286810870176106345173356164277260627250400116142607473
27075625183001565241815216181888478050730021534875841303440033518
08761068463150458850738731138707225402731227022768273187218146148
16748553628015267853255506114766877231568434030472746027364517746
120268284583202745273370710488...

output:

53873158858286810870176106345173356164277260627950400116142607473
27075625183001565241815216181888478050730021534875841303440033518
08761068463150458850738731138707225402731227022768273187218146148
16748553628015267853255506114766877231568434030472746027364517746
120268284583202745273370710488146441...

result:

ok 21 lines

Test #16:

score: 2.5
Accepted
time: 0ms
memory: 5692kb

input:

104 45
120020241403220040303340432212140042344032432
004300330012014000004342411431102432030104330
100211122100444014411042001403011420422233230
220330221321210222304124044312223321344401243
330103003204322341103132032400244434203021143
143204420100200312123233334212021340241103432
10131002041432341...

output:

120020241403220040303340432212140042344032432
004300330012014000004342411431102432030104330
100211122100444014411042001403011420422233230
220330221321210222304124044312223321344401243
330103003204322341103132032400244434203021143
143204420100200312123233334212021340241103432
101310020414323414113004...

result:

ok 104 lines

Test #17:

score: 2.5
Accepted
time: 2ms
memory: 5668kb

input:

509 499
0210202211011022112122102111011221020001102212212020221011221111000101112222222201210120012010202222201211002000001220122112111101122200202021020000110111121222120210212111022211001002110010110121212010000001200021210020000002110101220022212120011220211012201020120120210202001110211012201000...

output:

021020221101102211212210211101122102000110221221202022101122111100010111222222220121012001201020222220121100200000122012211211110112220020202102000011011112122212021021211102221100100211001011012121201000000120002121002000000211010122002221212001122021101220102012012021020200111021101220100022112100...

result:

ok 509 lines

Test #18:

score: 2.5
Accepted
time: 6ms
memory: 6280kb

input:

999 999
0111110101100100011011111000010111110000101100101101110000011111110101000010010010010110011111110011000101110110000010111100010010010110101100011100101011100001110100010010001100101111010100100101001111000001000101110111110000011011010010011111100100100001101010011011010011010100010101111100...

output:

011111010110010001101111100001011111000010110010110111000001111111010100001001001001011001111111001100010111011000001011110001001001011010110001110010101110000111010001001000110010111101010010010100111100000100010111011111000001101101001001111110010010000110101001101101001101010001010111110011011111...

result:

ok 999 lines

Test #19:

score: 2.5
Accepted
time: 6ms
memory: 6364kb

input:

999 999
1011100101111110101001111011000101011010101001000110100110101011011010000100010001001001001101010110100010100011011110111011000010000111010101000010111100100101111001001110010010011000111110010100100011011101000001001001011101010100011010011000010000111111010111011001111100100111101011111011...

output:

101110010111111010100111101100010101101010100100011010011010101101101000010001000100100100110101011010001010001101111011101100001000011101010100001011110010010111100100111001001001100011111001010010001101110100000100100101110101010001101001100001000011111101011101100111110010011110101111101100110100...

result:

ok 999 lines

Test #20:

score: 2.5
Accepted
time: 1ms
memory: 5824kb

input:

99 1
1
1
1
0
1
0
0
1
1
1
0
1
0
0
1
0
1
1
0
1
1
0
0
0
1
1
0
0
0
1
1
0
1
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
1
0
1
0
0
1
0
1
1
0
0
0
0
1
1
1
0
0
0
0
1
0
0
1
1
1
1
0
1
0
0
1
1
1
0
0
0
0
0
1
0
0
1
1
0
1
1
0
1
0
1
21 0 5

output:

1
1
1
0
1
0
0
1
1
1
0
1
0
0
1
0
1
1
0
1
1
5
5
5
1
1
0
0
0
1
1
0
1
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
1
0
1
0
0
1
0
1
1
0
0
0
0
1
1
1
0
0
0
0
1
0
0
1
1
1
1
0
1
0
0
1
1
1
0
0
0
0
0
1
0
0
1
1
0
1
1
0
1
0
1

result:

ok 99 lines