QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700821#48. Paint bucketTheZone50 ✓12ms13636kbC++231.6kb2024-11-02 13:25:232024-11-02 13:25:42

Judging History

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

  • [2024-11-02 13:25:42]
  • 评测
  • 测评结果:50
  • 用时:12ms
  • 内存:13636kb
  • [2024-11-02 13:25:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
namespace Main {
	const int N = 1000 + 5;
	const int dir[4][2]={{0, 1},{1, 0},{-1, 0},{0,-1}};
	int n, m;
	int sx,sy,c;
	char s[N][N];
	struct node {
		int x,y;
	};
	bool vis[N][N];
	node q[N*N];
	int main() {
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;++i) {
			scanf("%s",s[i]);
		}
		scanf("%d%d%d",&sx,&sy,&c);
		int l=1, r=0;
		q[r=1]=(node){
			sx,sy
		};
		int k=s[sx][sy]-'0';
		s[sx][sy]=c+'0';
		vis[sx][sy]=1;
		while(l<=r) {
			int x=q[l].x, y=q[l].y;
			l++;
//			cout<<x<<' '<<y<<'\n';
			for (int i=0;i<4;++i) {
				int nx=x+dir[i][0], ny=y+dir[i][1];
				if(0<=nx&&nx<n&&0<=ny&&ny<m) {
					if(!vis[nx][ny]) {
//						cout<<nx<<' '<<ny<<'\n';
						if(s[nx][ny]==k+'0') {
							vis[nx][ny]=1;
							s[nx][ny]=c+'0';
							q[++r]=(node){nx,ny};
						}
					}
				}
			}
		}
		for(int i=0;i<n;++i) {
			printf("%s\n",s[i]);
		}
		return 0;
	}
}
int main() {
	Main :: main();
	return 0;
}





















































































































































































































































































































































Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

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

input:

1 1
0
0 0 2

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 999
010000122000221212000001102122211002021202201110221220121222121222002201000022112022221100201011120001120222011111202102200122021122000201102120112000111220210100222022001010222211100202002001000000010122201010210200200201200111011010021221202001002001022101101221110120110102112120122201100102...

output:

010000122000221212000001102122211002021202201110221220121222121222002201000022112022221100201011120001120222011111202102200122021122000201102120112000111220210100222022001010222211100202002001000000010122201010210200200201200111011010021221202001002001022101101221110120110102112120122208800102122012...

result:

ok single line: '010000122000221212000001102122...0110012111220002220211210211021'

Test #3:

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

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 999 lines

Test #4:

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

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #5:

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

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #6:

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

input:

100 100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
333333333333333333333333333333333333333333333333333333333333333333333333333333333333300000...

output:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
77777777777777777777777777777777777777777777777777777777777777777777777777777777777770000000000000...

result:

ok 100 lines

Test #7:

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

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: 0ms
memory: 5880kb

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: 6012kb

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: 0ms
memory: 6004kb

input:

99 99
000111111111111111111110000000222222222200000000000002222222222111111111111111111111111111110000000
000111111111111111111100000000222222222200000000000002222222222222222222211111111111111111110000000
0000000000000000000000000000000000000000000000000000022222222222222222222000000000000000000000...

output:

000111111111111111111110000000222222222200000000000002222222222111111111111111111111111111110000000
000111111111111111111100000000222222222200000000000002222222222222222222211111111111111111110000000
000000000000000000000000000000000000000000000000000002222222222222222222200000000000000000000000000
...

result:

ok 99 lines

Test #11:

score: 2.5
Accepted
time: 3ms
memory: 9612kb

input:

999 999
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 999 lines

Test #12:

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

input:

2 2
00
00
0 0 5

output:

55
55

result:

ok 2 lines

Test #13:

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

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: 1ms
memory: 5916kb

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: 1ms
memory: 5912kb

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: 1ms
memory: 5944kb

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: 0ms
memory: 5912kb

input:

509 499
0210202211011022112122102111011221020001102212212020221011221111000101112222222201210120012010202222201211002000001220122112111101122200202021020000110111121222120210212111022211001002110010110121212010000001200021210020000002110101220022212120011220211012201020120120210202001110211012201000...

output:

021020221101102211212210211101122102000110221221202022101122111100010111222222220121012001201020222220121100200000122012211211110112220020202102000011011112122212021021211102221100100211001011012121201000000120002121002000000211010122002221212001122021101220102012012021020200111021101220100022112100...

result:

ok 509 lines

Test #18:

score: 2.5
Accepted
time: 3ms
memory: 6428kb

input:

999 999
0111110101100100011011111000010111110000101100101101110000011111110101000010010010010110011111110011000101110110000010111100010010010110101100011100101011100001110100010010001100101111010100100101001111000001000101110111110000011011010010011111100100100001101010011011010011010100010101111100...

output:

011111010110010001101111100001011111000010110010110111000001111111010100001001001001011001111111001100010111011000001011110001001001011010110001110010101110000111010001001000110010111101010010010100111100000100010111011111000001101101001001111110010010000110101001101101001101010001010111110011011111...

result:

ok 999 lines

Test #19:

score: 2.5
Accepted
time: 3ms
memory: 6376kb

input:

999 999
1011100101111110101001111011000101011010101001000110100110101011011010000100010001001001001101010110100010100011011110111011000010000111010101000010111100100101111001001110010010011000111110010100100011011101000001001001011101010100011010011000010000111111010111011001111100100111101011111011...

output:

101110010111111010100111101100010101101010100100011010011010101101101000010001000100100100110101011010001010001101111011101100001000011101010100001011110010010111100100111001001001100011111001010010001101110100000100100101110101010001101001100001000011111101011101100111110010011110101111101100110100...

result:

ok 999 lines

Test #20:

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

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