QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#493322 | #9164. Toy | nhuang685# | 0 | 6ms | 12276kb | C++20 | 2.2kb | 2024-07-27 06:01:13 | 2024-07-27 06:01:13 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int w, h, k, l;
std::cin >> w >> h >> k >> l;
int xh, yh, xv, yv;
std::cin >> xh >> yh >> xv >> yv;
int sx = xv, sy = yh;
int ex = -1, ey = -1;
std::vector block(w, std::vector<bool>(h));
std::vector<std::vector<int>> loc_r(w, {-1}), loc_c(h, {-1});
for (int j = 0; j < h; ++j) {
for (int i = 0; i < w; ++i) {
char c;
std::cin >> c;
block[i][j] = c == 'X';
if (c == '*') {
ex = i;
ey = j;
}
if (block[i][j]) {
loc_r[i].push_back(j);
loc_c[j].push_back(i);
}
}
}
for (int i = 0; i < w; ++i) {
loc_r[i].push_back(h);
}
for (int i = 0; i < h; ++i) {
loc_c[i].push_back(w);
}
auto near_r = [&](int x, int y) -> std::pair<int, int> {
auto it = std::lower_bound(loc_r[x].begin(), loc_r[x].end(), y);
return {*std::prev(it), *it};
};
auto near_c = [&](int x, int y) -> std::pair<int, int> {
auto it = std::lower_bound(loc_c[y].begin(), loc_c[y].end(), x);
return {*std::prev(it), *it};
};
std::vector vis(w, std::vector<bool>(h));
auto inter = [&](int l1, int r1, int l2, int r2) {
return std::max(0, std::min(r1, r2) - std::max(l1, l2));
};
auto dfs = [&](auto &self, int x, int y) -> void {
if (x == ex && y == ey) {
std::cout << "YES\n";
std::exit(0);
}
// move row
for (int d : {-1, 1}) {
if (x + d < 0 || x + d >= w || vis[x + d][y]) {
continue;
}
auto [cl, cr] = near_r(x, y);
auto [nl, nr] = near_r(x + d, y);
int width = inter(cl, cr, nl, nr) - 1;
if (width >= l) {
vis[x + d][y] = true;
self(self, x + d, y);
}
}
// move column
for (int d : {-1, 1}) {
if (y + d < 0 || y + d >= h || vis[x][y + d]) {
continue;
}
auto [cl, cr] = near_c(x, y);
auto [nl, nr] = near_c(x, y + d);
int width = inter(cl, cr, nl, nr) - 1;
if (width >= k) {
vis[x][y + d] = true;
self(self, x, y + d);
}
}
};
dfs(dfs, sx, sy);
std::cout << "NO\n";
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 14
Accepted
time: 0ms
memory: 3604kb
input:
32 16 23 15 3 8 4 1 ................................ ................................ ................................ ................................ ................................ *............................... ................................ ................................ ...................
output:
YES
result:
ok answer is YES
Test #2:
score: 14
Accepted
time: 0ms
memory: 3876kb
input:
50 50 22 14 26 34 36 33 .................................................. .................................................. .................................................. .................................................. .................................................. ........................
output:
YES
result:
ok answer is YES
Test #3:
score: 14
Accepted
time: 0ms
memory: 3700kb
input:
50 50 50 50 0 18 2 0 .................................................. ...............................................X.. .................................................. .................................................. .................................................. ...........................
output:
NO
result:
ok answer is NO
Test #4:
score: 14
Accepted
time: 0ms
memory: 3532kb
input:
5 47 4 47 1 25 3 0 .X... ..... ..... .X... ..... ..... ..... ..... ..... ..... ..... ..... ..*.. ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... X.... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... .....
output:
YES
result:
ok answer is YES
Test #5:
score: 14
Accepted
time: 0ms
memory: 3500kb
input:
50 50 29 46 11 5 29 3 .................................................. .................................................. .................................................. .................................................. ....................X.......................X..... ..........................
output:
NO
result:
ok answer is NO
Test #6:
score: 14
Accepted
time: 0ms
memory: 3544kb
input:
50 50 50 50 0 37 22 0 ............X.............X..............X........ .................................................. .................................................. ....................................X............. ................................X................. ....................X.....
output:
NO
result:
ok answer is NO
Test #7:
score: 14
Accepted
time: 0ms
memory: 3600kb
input:
27 34 19 18 5 29 20 14 ............X..X.X.X..XX..X .....X..X...XX............. .......X.X........X........ X...................X...X.. ....XX..................... .................X........X ..........X.X.....X.......X ..........X......X....X.... X..X........XX.....X....... ..X.X............X..........
output:
NO
result:
ok answer is NO
Test #8:
score: 14
Accepted
time: 0ms
memory: 3552kb
input:
50 50 16 16 21 35 36 33 .X.............XX....X...X.......X................ .................X.......X.........X........X..... ...X........X......XX........X.......X...........X .X......X.......X.....X.X................X.XX....X ......X.........................X.............X.X. ........X...X..X...X....
output:
NO
result:
ok answer is NO
Test #9:
score: 14
Accepted
time: 0ms
memory: 3772kb
input:
50 50 50 50 0 20 3 0 .......X.......................................... ....X............X.......X.......X...........X.... .......X....X........X..X.......X..........X..X... .X......X.......X.................X.............X. .................X.X....X..XX..................... .......X...................
output:
NO
result:
ok answer is NO
Test #10:
score: 14
Accepted
time: 0ms
memory: 3556kb
input:
4 7 4 5 0 2 0 1 .X.. .X.. .... ..X. ..X. .XX* XXXX
output:
NO
result:
ok answer is NO
Test #11:
score: 14
Accepted
time: 0ms
memory: 3584kb
input:
50 50 13 13 2 46 11 36 .X.X.X.....XX.XX.X..XX..XXXXXXX.XXX...XX.X.X.XXXX. .X..X...X.X.X.X.X.X..XX..XX.XXXX..X.X..XXX...X..X. X..X...X....XX....XX......X...X..XXX.X.X..X.X..... ...X.XX...X..XX.X..XX.X...X.X...X.XXX.XX..XX..XX.. ..X.XX...X.X.X..X.X.......X.X......X..X..X...X.X.X ......XX......X..X..X....
output:
NO
result:
ok answer is NO
Test #12:
score: 14
Accepted
time: 0ms
memory: 3840kb
input:
50 50 50 50 0 46 6 0 XX.....X....X...X.X.X..XX..XX...X.XX..X.......X... XXX........X.X.X.XX..X..XX..XXX....X.XX.....X...XX ..X.X...X.X.........X..X....XX....X*XXXXXXX...XX.. ....X..XX....X.X.X..X..XXX...XXX..XXX.X..X.XX.XXXX XXX......X.X.....X.X.........XXXXX.XX..X.X.X.XXX.X .X.....XXXX....X...X.XXX...
output:
NO
result:
ok answer is NO
Test #13:
score: 14
Accepted
time: 0ms
memory: 3784kb
input:
48 50 24 21 3 9 6 3 ................................................ ................................................ ................................................ ................................................ ................................................ ......................................
output:
NO
result:
ok answer is NO
Test #14:
score: 14
Accepted
time: 0ms
memory: 3708kb
input:
50 45 23 25 0 27 14 12 .................................................. .................................................. .................................................. .................................................. .................................................. .........................
output:
NO
result:
ok answer is NO
Test #15:
score: 14
Accepted
time: 0ms
memory: 3736kb
input:
50 46 23 25 2 25 20 16 .................................................. .................................................. .................................................. .................................................. .................................................. .........................
output:
NO
result:
ok answer is NO
Test #16:
score: 14
Accepted
time: 0ms
memory: 3988kb
input:
50 50 25 25 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
NO
result:
ok answer is NO
Test #17:
score: 14
Accepted
time: 0ms
memory: 3828kb
input:
50 50 24 24 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
NO
result:
ok answer is NO
Test #18:
score: 14
Accepted
time: 0ms
memory: 3848kb
input:
50 50 23 23 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
NO
result:
ok answer is NO
Test #19:
score: 14
Accepted
time: 0ms
memory: 3860kb
input:
50 50 25 25 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
YES
result:
ok answer is YES
Test #20:
score: 14
Accepted
time: 1ms
memory: 4016kb
input:
50 50 24 24 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
YES
result:
ok answer is YES
Test #21:
score: 14
Accepted
time: 1ms
memory: 3772kb
input:
50 50 23 23 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ............................
output:
YES
result:
ok answer is YES
Test #22:
score: 14
Accepted
time: 0ms
memory: 3612kb
input:
50 50 12 12 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ ............................
output:
YES
result:
ok answer is YES
Test #23:
score: 14
Accepted
time: 0ms
memory: 3880kb
input:
50 50 11 11 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ ............................
output:
YES
result:
ok answer is YES
Test #24:
score: 14
Accepted
time: 0ms
memory: 3988kb
input:
50 50 12 12 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ ............................
output:
YES
result:
ok answer is YES
Test #25:
score: 14
Accepted
time: 0ms
memory: 3772kb
input:
50 50 11 11 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ ............................
output:
YES
result:
ok answer is YES
Test #26:
score: 14
Accepted
time: 0ms
memory: 3704kb
input:
50 50 10 10 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ ............................
output:
YES
result:
ok answer is YES
Test #27:
score: 14
Accepted
time: 0ms
memory: 3700kb
input:
50 50 9 9 0 0 0 0 .........................X.......................* .........................X........................ .........................X........................ .........................X........................ .........................X........................ .........................X....
output:
YES
result:
ok answer is YES
Test #28:
score: 14
Accepted
time: 0ms
memory: 3716kb
input:
50 47 8 8 0 0 0 0 .................................................. .................................................. .................................................. .................................................. .................................................. ..............................
output:
YES
result:
ok answer is YES
Test #29:
score: 0
Wrong Answer
time: 0ms
memory: 3648kb
input:
45 48 10 10 0 0 0 0 ............................................. ............................................. ............................................. ............................................. ............................................. ............................................. .......
output:
YES
result:
wrong answer expected NO, found YES
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #89:
score: 9
Accepted
time: 0ms
memory: 3736kb
input:
105 31 8 4 70 27 75 26 ......................................................................................................... ......................................................................................................... ....................................................................
output:
YES
result:
ok answer is YES
Test #90:
score: 9
Accepted
time: 2ms
memory: 10368kb
input:
300 300 4 8 231 246 234 240 ...................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #91:
score: 9
Accepted
time: 1ms
memory: 3904kb
input:
300 300 10 10 151 143 155 137 .................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #92:
score: 9
Accepted
time: 0ms
memory: 4220kb
input:
159 68 6 2 95 54 98 54 .........................................................................X..................................................................................... ..........................X..................................................X..........................................
output:
YES
result:
ok answer is YES
Test #93:
score: 9
Accepted
time: 0ms
memory: 5456kb
input:
300 300 10 10 11 147 12 143 .....................................................................X.................X.......................................*X..............................................X...................................................................................................
output:
YES
result:
ok answer is YES
Test #94:
score: 9
Accepted
time: 3ms
memory: 6672kb
input:
300 300 10 10 289 237 298 236 .........................................................................................X.......................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #95:
score: 9
Accepted
time: 1ms
memory: 3592kb
input:
277 111 6 9 109 9 112 5 ...................X..XX...........X.......X..................X...X.......X........X......X...........X....................X.......................X..X..X.........XX...................X..............X..........X..................X................X...................X............
output:
NO
result:
ok answer is NO
Test #96:
score: 9
Accepted
time: 2ms
memory: 3820kb
input:
300 300 6 6 126 5 131 1 .......X............XX..............X...X....XX..........X..X........X.X...X...........X.................X...............X..............X.....XX.............X....................................XX....X................X........X...................X.....X..........................
output:
NO
result:
ok answer is NO
Test #97:
score: 9
Accepted
time: 1ms
memory: 3836kb
input:
300 300 10 10 30 92 34 92 ...X..........X.........................X....................XX........XX......X..X.......X..................X..X...X..X.........X..................X.........X...........................XX................X....XX.......................X...........X..............................
output:
NO
result:
ok answer is NO
Test #98:
score: 9
Accepted
time: 0ms
memory: 3772kb
input:
121 248 8 4 20 157 23 156 ...XXX.....XX..XXXX...XX.XXX....X..XXX....XX.XX..X..XX.X...X...X.X............X....X...XXX..XX..X..X....X.X..X..X.....XXX ...XX..XX.XX..XX..XX..X...X..X..X.......X.X..X.XX......X....XX.X..X..X.X.X...X..XXX.XXXX...XXXX..X..X...X.XX........X.X.X XXXXX....X.X.X..XXXX.XX..XX.XX...
output:
NO
result:
ok answer is NO
Test #99:
score: 9
Accepted
time: 2ms
memory: 4292kb
input:
300 300 9 5 55 124 55 121 XX.X...X..X.X..X.....X..X..X.X.X...XX.XXX...XXX........XXX.........X..XX..X.X......X....XXXXX.X.X.X.X......X..X.X...XXXX..X....X.XXXX....XX..XX.X......XX.XX..X.....X.X.X.XXXX.X.XX.XXX....XX.X..X.X.XX.X.X...XX.X.X.XX...X.....X..XXX..X.XX...XXX...X.XXX...XX..X....XX.XXX.X.XXX...
output:
NO
result:
ok answer is NO
Test #100:
score: 9
Accepted
time: 2ms
memory: 4120kb
input:
300 300 10 10 94 163 96 156 X..X.....X..XXX.X.XXXXX..XXX..X....X..XX..XXX...XXX....X.XXXXX...XX...XX.X...XX.X...XX..XX...X.X...X.X.XX...XX..X..X.....X.X........X.XXX...XXX.XX....X.X.X....X......XXX.XX.XX..XXXX...XX....X.X.X.X...XXX.......XX..X..XX.....X...XX..X...XX.....XXX.XXXXX..X.X...X...X.XX..X....
output:
NO
result:
ok answer is NO
Test #101:
score: 9
Accepted
time: 5ms
memory: 11208kb
input:
286 296 9 9 19 286 26 279 .....................................................................................................................................................................................................................................................................................
output:
NO
result:
ok answer is NO
Test #102:
score: 9
Accepted
time: 0ms
memory: 10140kb
input:
284 284 9 9 36 50 40 42 .......................................................................................................................................................................................................................................................................................
output:
NO
result:
ok answer is NO
Test #103:
score: 9
Accepted
time: 0ms
memory: 10136kb
input:
270 299 10 9 35 258 39 253 .............................................................................................................................................................................................................................................................................. .....
output:
NO
result:
ok answer is NO
Test #104:
score: 9
Accepted
time: 3ms
memory: 11956kb
input:
300 300 10 10 0 0 0 0 .........................................................................................................................................................................................................................................................................................
output:
NO
result:
ok answer is NO
Test #105:
score: 9
Accepted
time: 6ms
memory: 12024kb
input:
300 300 9 9 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
NO
result:
ok answer is NO
Test #106:
score: 9
Accepted
time: 0ms
memory: 12104kb
input:
300 300 8 8 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
NO
result:
ok answer is NO
Test #107:
score: 9
Accepted
time: 4ms
memory: 12276kb
input:
300 300 10 10 0 0 0 0 .........................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #108:
score: 9
Accepted
time: 4ms
memory: 12228kb
input:
300 300 9 9 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #109:
score: 9
Accepted
time: 0ms
memory: 12060kb
input:
300 300 8 8 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #110:
score: 9
Accepted
time: 3ms
memory: 7852kb
input:
300 300 10 10 0 0 0 0 ......................................................................................................................................................X..................................................................................................................................
output:
YES
result:
ok answer is YES
Test #111:
score: 9
Accepted
time: 3ms
memory: 8140kb
input:
300 300 9 9 0 0 0 0 ......................................................................................................................................................X....................................................................................................................................
output:
YES
result:
ok answer is YES
Test #112:
score: 9
Accepted
time: 4ms
memory: 9848kb
input:
300 300 10 10 0 0 0 0 ......................................................................................................................................................X..................................................................................................................................
output:
YES
result:
ok answer is YES
Test #113:
score: 9
Accepted
time: 0ms
memory: 9868kb
input:
300 300 9 9 0 0 0 0 ......................................................................................................................................................X....................................................................................................................................
output:
YES
result:
ok answer is YES
Test #114:
score: 9
Accepted
time: 0ms
memory: 9932kb
input:
300 300 8 8 0 0 0 0 ......................................................................................................................................................X....................................................................................................................................
output:
YES
result:
ok answer is YES
Test #115:
score: 9
Accepted
time: 3ms
memory: 9864kb
input:
300 300 7 7 0 0 0 0 ......................................................................................................................................................X....................................................................................................................................
output:
YES
result:
ok answer is YES
Test #116:
score: 9
Accepted
time: 1ms
memory: 4308kb
input:
300 289 8 8 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
YES
result:
ok answer is YES
Test #117:
score: 0
Wrong Answer
time: 0ms
memory: 10252kb
input:
285 293 5 5 0 0 0 0 ...........................................................................................................................................................................................................................................................................................
output:
YES
result:
wrong answer expected NO, found YES
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%