QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90131 | #48. Paint bucket | ChatGPT | 5 | 127ms | 148716kb | C++ | 1.2kb | 2023-03-22 13:37:16 | 2023-03-22 13:37:18 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 1000;
int R, C, Y, X, K;
int grid[MAXN][MAXN];
bool visited[MAXN][MAXN];
// Check if a given position is within bounds and has the same color as the target
bool isValid(int r, int c, int target) {
return r >= 0 && r < R && c >= 0 && c < C && grid[r][c] == target && !visited[r][c];
}
// Recursive function to fill all connected pixels of the same color with the target color
void fill(int r, int c, int target) {
visited[r][c] = true;
grid[r][c] = K;
if (isValid(r+1, c, target)) fill(r+1, c, target);
if (isValid(r-1, c, target)) fill(r-1, c, target);
if (isValid(r, c+1, target)) fill(r, c+1, target);
if (isValid(r, c-1, target)) fill(r, c-1, target);
}
int main() {
cin >> R >> C;
for (int r = 0; r < R; r++) {
for (int c = 0; c < C; c++) {
cin >> grid[r][c];
}
}
cin >> Y >> X >> K;
fill(Y, X, grid[Y][X]);
for (int r = 0; r < R; r++) {
for (int c = 0; c < C; c++) {
cout << grid[r][c];
}
cout << endl;
}
return 0;
}
詳細信息
Test #1:
score: 2.5
Accepted
time: 2ms
memory: 3440kb
input:
1 1 0 0 0 2
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Wrong Answer
time: 2ms
memory: 3344kb
input:
1 999 010000122000221212000001102122211002021202201110221220121222121222002201000022112022221100201011120001120222011111202102200122021122000201102120112000111220210100222022001010222211100202002001000000010122201010210200200201200111011010021221202001002001022101101221110120110102112120122201100102...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '010000122000221212000001102122...0110012111220002220211210211021', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #3:
score: 0
Wrong Answer
time: 127ms
memory: 148080kb
input:
999 999 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '111111111111111111111111111111...1111111111111111111111111111111', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #4:
score: 0
Wrong Answer
time: 51ms
memory: 5376kb
input:
999 999 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000000000000000000000000000000', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #5:
score: 0
Wrong Answer
time: 98ms
memory: 148716kb
input:
999 999 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
002147483647000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000000000000000000000000000000', found: '002147483647000000000000000000...0000000000000000000000000000000'
Test #6:
score: 0
Wrong Answer
time: 4ms
memory: 6776kb
input:
100 100 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 333333333333333333333333333333333333333333333333333333333333333333333333333333333333300000...
output:
0021474836470000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000000000000000000000000000000', found: '002147483647000000000000000000...0000000000000000000000000000000'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 3300kb
input:
10 10 0000000000 0000000000 0000000000 0002222222 0002222222 0002222222 0002222222 0002222222 0002222222 0000000000 4 3 8
output:
0002222222222222222222222222222222222222222220 4380000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000
result:
wrong answer 1st lines differ - expected: '0000000000', found: '0002222222222222222222222222222222222222222220'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3612kb
input:
37 41 00000000000000000000000000000000000000000 00003333332222222000000000000000000000000 00003333332222222400000000000000000000000 00003333332222222400000000000000000000000 00000000002222222000000000000000000000000 01111000002222222000000000000000000000000 01111000002222222000000000000000000000000 ...
output:
02147483647000000000000000000000000000000000000000 00000000000000000000000000000000000000000 00000000000000000000000000000000000000000 00000000000000000000000000000000000000000 00000000000000000000000000000000000000000 00000000000000000000000000000000000000000 000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '99999999999999999999999999999999999999999', found: '02147483647000000000000000000000000000000000000000'
Test #9:
score: 0
Wrong Answer
time: 5ms
memory: 4308kb
input:
101 23 00000000000000000000000 00000000000000000000000 00000000000000000000000 00550000000000000000000 00550000000000000000000 00550000000000666666666 00000000000000666666666 00000000000033666666666 00000000000033666666666 00000000000033666666666 00000000000033666666666 00000000000033666666666 00000...
output:
00021474836470000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 00000000000000000000000 000...
result:
wrong answer 1st lines differ - expected: '00000000000000000000000', found: '00021474836470000000000000000000'
Test #10:
score: 0
Wrong Answer
time: 2ms
memory: 3324kb
input:
99 99 000111111111111111111110000000222222222200000000000002222222222111111111111111111111111111110000000 000111111111111111111100000000222222222200000000000002222222222222222222211111111111111111110000000 0000000000000000000000000000000000000000000000000000022222222222222222222000000000000000000000...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ...
result:
wrong answer 1st lines differ - expected: '000111111111111111111110000000...1111111111111111111111110000000', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #11:
score: 0
Wrong Answer
time: 82ms
memory: 148680kb
input:
999 999 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
000000000000000000000000214748364700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000000000000000000000000000000', found: '000000000000000000000000214748...0000000000000000000000000000000'
Test #12:
score: 0
Wrong Answer
time: 2ms
memory: 3340kb
input:
2 2 00 00 0 0 5
output:
00 00
result:
wrong answer 1st lines differ - expected: '55', found: '00'
Test #13:
score: 0
Wrong Answer
time: 2ms
memory: 3508kb
input:
10 10 0020000000 0020000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 7 0 5
output:
0000000000 7050000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000
result:
wrong answer 1st lines differ - expected: '5525555555', found: '0000000000'
Test #14:
score: 0
Wrong Answer
time: 1ms
memory: 3348kb
input:
10 10 1011010001 1101110010 1011100101 0001000100 0111011101 1001000011 0010010001 1100011010 1111100001 1001100101 8 3 7
output:
0110111001010111001011000100111011101100100001110010001110001101011111000011001100101 8370000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000
result:
wrong answer 1st lines differ - expected: '1011010001', found: '011011100101011100101100010011...1110001101011111000011001100101'
Test #15:
score: 0
Wrong Answer
time: 2ms
memory: 3236kb
input:
21 65 53873158858286810870176106345173356164277260627250400116142607473 27075625183001565241815216181888478050730021534875841303440033518 08761068463150458850738731138707225402731227022768273187218146148 16748553628015267853255506114766877231568434030472746027364517746 120268284583202745273370710488...
output:
00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '538731588582868108701761063451...6164277260627950400116142607473', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #16:
score: 0
Wrong Answer
time: 0ms
memory: 3356kb
input:
104 45 120020241403220040303340432212140042344032432 004300330012014000004342411431102432030104330 100211122100444014411042001403011420422233230 220330221321210222304124044312223321344401243 330103003204322341103132032400244434203021143 143204420100200312123233334212021340241103432 10131002041432341...
output:
000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000 000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '120020241403220040303340432212140042344032432', found: '000000000000000000000000000000000000000000000'
Test #17:
score: 0
Wrong Answer
time: 26ms
memory: 3472kb
input:
509 499 0210202211011022112122102111011221020001102212212020221011221111000101112222222201210120012010202222201211002000001220122112111101122200202021020000110111121222120210212111022211001002110010110121212010000001200021210020000002110101220022212120011220211012201020120120210202001110211012201000...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '021020221101102211212210211101...1111120010101022202002000222121', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #18:
score: 0
Wrong Answer
time: 43ms
memory: 3328kb
input:
999 999 0111110101100100011011111000010111110000101100101101110000011111110101000010010010010110011111110011000101110110000010111100010010010110101100011100101011100001110100010010001100101111010100100101001111000001000101110111110000011011010010011111100100100001101010011011010011010100010101111100...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '011111010110010001101111100001...1010101010111000110110000011010', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #19:
score: 0
Wrong Answer
time: 41ms
memory: 3384kb
input:
999 999 1011100101111110101001111011000101011010101001000110100110101011011010000100010001001001001101010110100010100011011110111011000010000111010101000010111100100101111001001110010010011000111110010100100011011101000001001001011101010100011010011000010000111111010111011001111100100111101011111011...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '101110010111111010100111101100...0011001100000100001011111001001', found: '000000000000000000000000000000...0000000000000000000000000000000'
Test #20:
score: 2.5
Accepted
time: 2ms
memory: 3828kb
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