# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1045653 |
2024-08-06T06:46:10 Z |
dilanyan |
Toy (CEOI24_toy) |
C++17 |
|
1500 ms |
6492 KB |
//-------------dilanyan------------\\
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//------------------Kargpefines--------------------\\
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
void KarginSet(string name = "") {
ios_base::sync_with_stdio(false); cin.tie(NULL);
if (name.size()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
//-------------------KarginConstants------------------\\
const ll mod = 1e9 + 7;
const ll inf = 2e9;
//-------------------KarginCode-----------------------\\
const int N = 1505, M = 1000005;
int w, h, k, l;
int w_h, h_h, w_v, h_v;
char a[N][N];
int dp[N][N];
bool vis[N][N];
int dh[4] = { 1,-1,0,0 };
int dw[4] = { 0,0,1,-1 };
bool valid(int h_s, int w_s, int h_e, int w_e, int d) {
if (h_e < 0 || h_e >= h || w_e < 0 || w_e >= w) return false;
if (a[h_e][w_e] == 'X' || vis[h_e][w_e]) return false;
if (d) { // nerqev verev
for (int i = max(0, w_s - k);i < min(w, w_s + k);i++) {
bool flag = true;
for (int j = i;j - i < k;j++) {
if (a[h_s][j] == 'X' || a[h_e][j] == 'X') {
flag = false;
continue;
}
}
if (flag) return true;
}
return false;
}
else {
for (int i = max(0, h_s - l);i < min(h, h_s + l);i++) {
bool flag = true;
for (int j = i;j - i < l;j++) {
if (a[j][w_s] == 'X' || a[j][w_e] == 'X') {
flag = false;
continue;
}
}
if (flag) return true;
}
return false;
}
}
void KarginSolve() {
cin >> w >> h >> k >> l;
cin >> w_h >> h_h >> w_v >> h_v;
int h_e, w_e;;
for (int i = 0;i < h;i++) {
for (int j = 0;j < w;j++) {
cin >> a[i][j];
if (a[i][j] == '*') {
h_e = i, w_e = j;
}
vis[i][j] = false;
dp[i][j] = inf;
}
}
int w_s = w_v, h_s = h_h;
queue<pair<int, int>> q;
q.push({ w_s,h_s });
vis[h_s][w_s] = true;
while (!q.empty()) {
int w_u = q.front().first, h_u = q.front().second;
q.pop();
for (int i = 0;i < 4;i++) {
int h_x = h_u + dh[i], w_x = w_u + dw[i];
if (valid(h_u, w_u, h_x, w_x, (dh[i] != 0))) {
vis[w_x][h_x] = true;
q.push({ w_x,h_x });
}
}
}
if (vis[h_e][w_e]) {
cout << "YES\n";
}
else cout << "NO\n";
}
int main() {
KarginSet();
int test = 1;
//cin >> test;
while (test--) {
KarginSolve();
}
return 0;
}
Compilation message
Main.cpp:1:1: warning: multi-line comment [-Wcomment]
1 | //-------------dilanyan------------\\
| ^
Main.cpp:8:1: warning: multi-line comment [-Wcomment]
8 | //------------------Kargpefines--------------------\\
| ^
Main.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | //-------------------KarginConstants------------------\\
| ^
Main.cpp:32:1: warning: multi-line comment [-Wcomment]
32 | //-------------------KarginCode-----------------------\\
| ^
Main.cpp: In function 'void KarginSet(std::string)':
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'void KarginSolve()':
Main.cpp:106:21: warning: 'w_e' may be used uninitialized in this function [-Wmaybe-uninitialized]
106 | if (vis[h_e][w_e]) {
| ~~~~~~~~~~~~^
Main.cpp:106:21: warning: 'h_e' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1577 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |