Submission #1060763

#TimeUsernameProblemLanguageResultExecution timeMemory
1060763qlu11708Toy (CEOI24_toy)C++14
0 / 100
1 ms4444 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1504; bool vis[N][N]; int lleft[N][N], rright[N][N], ttop[N][N], bbottom[N][N]; int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1}; int h, w, k, l; void dfs(int x, int y) { vis[x][y] = 1; // printf("(%d, `%d)\n", x, y); for (int z = 0; z < 4; z++) { int a = x + dx[z], b = y + dy[z]; if (a <= h && a >= 1 && b <= w && b >= 1 && !vis[a][b] && lleft[a][b]) { if (z < 2 && (min(lleft[x][y], lleft[a][b]) + min(rright[x][y], rright[a][b]) >= k)) { dfs(a, b); } if (z > 1 && (min(ttop[x][y], ttop[a][b]) + min(bbottom[x][y], bbottom[a][b]) >= l)) { dfs(a, b); } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> w >> h >> k >> l; int xh, yh, xv, yv; cin >> xh >> yh >> xv >> yv; int x = xh, y = yv, xend, yend; x++; y++; vector<vector<char>> grid(h + 1, vector<char>(w + 1)); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> grid[i][j]; if (grid[i][j] == '*') { xend = i; yend = j; } } } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (grid[i][j] == 'X') { lleft[i][j] = ttop[i][j] = 0; continue; } lleft[i][j] = lleft[i][j - 1] + 1; ttop[i][j] = ttop[i - 1][j] + 1; } } for (int i = h; i >= 1; i--) { for (int j = w; j >= 1; j--) { if (grid[i][j] == 'X') { rright[i][j] = bbottom[i][j] = 0; continue; } rright[i][j] = rright[i][j + 1] + 1; bbottom[i][j] = bbottom[i + 1][j] + 1; } } dfs(x, y); cout << (vis[xend][yend] ? "YES" : "NO") << "\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:65:28: warning: 'yend' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |     cout << (vis[xend][yend] ? "YES" : "NO") << "\n";
      |              ~~~~~~~~~~~~~~^
Main.cpp:65:28: warning: 'xend' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...