답안 #1062191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062191 2024-08-16T21:03:22 Z beaconmc Toy (CEOI24_toy) C++14
0 / 100
23 ms 13600 KB
#include <bits/stdc++.h>
 
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 
using namespace std;

ll sus[100000];

ll grid[2000][2000];
vector<ll> rows[2000];
vector<ll> cols[2000];
bool visited[2000][2000];


ll rowdist(ll a, ll b){
	ll sus = upper_bound(rows[a].begin(), rows[a].end(), b) - rows[a].begin();

	ll ans = 1;
	ans += abs(b - rows[a][sus])-1;
	ans += abs(b-rows[a][sus-1])-1;
	return ans;
}

ll coldist(ll a, ll b){
	ll sus = upper_bound(cols[b].begin(), cols[b].end(), a) - cols[b].begin();

	ll ans = 1;
	ans += abs(a - cols[b][sus])-1;
	ans += abs(a - cols[b][sus-1])-1;
	return ans;
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll w,h,k,l;
	cin >> w >> h >> k >> l;

	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	a = b; b = c;
	ll x,y;

	FOR(i,0,h){
		string temp;
		cin >> temp;
		FOR(j,0,w){
			visited[i][j] = 0;
			grid[i][j] = temp[j];
			if (grid[i][j] == 'X'){
				rows[i].push_back(j);
				cols[j].push_back(i);
			}
			if (grid[i][j] == '*'){
				x=i;
				y=j;
			}
		}
	}

	FOR(i,0,h) rows[i].push_back(-1), rows[i].push_back(w), sort(rows[i].begin(), rows[i].end());
	FOR(i,0,w) cols[i].push_back(-1), cols[i].push_back(h), sort(cols[i].begin(), cols[i].end());



	FOR(i,0,h){
		FOR(j,0,w){

			if (rowdist(i,j) < k || coldist(i,j) < l) grid[i][j] = 'X';
		}
	}

	// FOR(i,0,h){
	// 	FOR(j,0,w){
	// 		cout << (char) grid[i][j];
	// 	}
	// 	cout << endl;
	// }


	bool flag = false;

	vector<vector<ll>> stack;

	stack.push_back({a,b});
	while (stack.size()){
		vector<ll> node = stack[stack.size()-1];
		if (node[0] == x && node[1] == y){
			flag = true;
			break;
		}
		stack.pop_back();

		vector<vector<ll>> nxt = {{node[0], node[1]+1},{node[0], node[1]-1},{node[0]+1, node[1]},{node[0]-1, node[1]}};

		for (auto&i : nxt){
			if (0<=i[0] && i[0] < h && 0<=i[1] && i[1] < w && grid[i[0]][i[1]] != 'X' && !visited[i[0]][i[1]]){
				visited[i[0]][i[1]] = 1;
				stack.push_back({i[0], i[1]});

			}
		}

	}
	if (flag) cout << "YES";
	else cout << "NO";




}




Compilation message

Main.cpp: In function 'int main()':
Main.cpp:92:20: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |   if (node[0] == x && node[1] == y){
Main.cpp:92:20: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 1 ms 4700 KB Output is correct
23 Correct 1 ms 4700 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4700 KB Output is correct
26 Correct 1 ms 4700 KB Output is correct
27 Correct 1 ms 4700 KB Output is correct
28 Correct 1 ms 4700 KB Output is correct
29 Correct 1 ms 4700 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 1 ms 4700 KB Output is correct
32 Correct 1 ms 4700 KB Output is correct
33 Correct 1 ms 4700 KB Output is correct
34 Correct 1 ms 4700 KB Output is correct
35 Correct 1 ms 4700 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Incorrect 1 ms 4700 KB Output isn't correct
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 1 ms 4700 KB Output is correct
23 Correct 1 ms 4700 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4700 KB Output is correct
26 Correct 1 ms 4700 KB Output is correct
27 Correct 1 ms 4700 KB Output is correct
28 Correct 1 ms 4700 KB Output is correct
29 Correct 1 ms 4700 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 1 ms 4700 KB Output is correct
32 Correct 1 ms 4700 KB Output is correct
33 Correct 1 ms 4700 KB Output is correct
34 Correct 1 ms 4700 KB Output is correct
35 Correct 1 ms 4700 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Incorrect 1 ms 4700 KB Output isn't correct
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 7 ms 12364 KB Output is correct
5 Correct 9 ms 12308 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 7 ms 11672 KB Output is correct
8 Correct 13 ms 12364 KB Output is correct
9 Correct 2 ms 6744 KB Output is correct
10 Correct 5 ms 11100 KB Output is correct
11 Correct 5 ms 11232 KB Output is correct
12 Correct 2 ms 9052 KB Output is correct
13 Correct 4 ms 11880 KB Output is correct
14 Correct 4 ms 11892 KB Output is correct
15 Correct 17 ms 13588 KB Output is correct
16 Correct 16 ms 13332 KB Output is correct
17 Correct 16 ms 13332 KB Output is correct
18 Correct 18 ms 13588 KB Output is correct
19 Correct 18 ms 13588 KB Output is correct
20 Correct 18 ms 13588 KB Output is correct
21 Correct 13 ms 13460 KB Output is correct
22 Correct 11 ms 13568 KB Output is correct
23 Correct 11 ms 13588 KB Output is correct
24 Correct 11 ms 13588 KB Output is correct
25 Correct 11 ms 13584 KB Output is correct
26 Correct 10 ms 12308 KB Output is correct
27 Correct 16 ms 12480 KB Output is correct
28 Correct 15 ms 12564 KB Output is correct
29 Correct 10 ms 12304 KB Output is correct
30 Correct 17 ms 13588 KB Output is correct
31 Correct 16 ms 13588 KB Output is correct
32 Correct 13 ms 13388 KB Output is correct
33 Correct 23 ms 13388 KB Output is correct
34 Correct 15 ms 11280 KB Output is correct
35 Correct 14 ms 13328 KB Output is correct
36 Correct 3 ms 11356 KB Output is correct
37 Incorrect 12 ms 13600 KB Output isn't correct
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 1 ms 4700 KB Output is correct
23 Correct 1 ms 4700 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4700 KB Output is correct
26 Correct 1 ms 4700 KB Output is correct
27 Correct 1 ms 4700 KB Output is correct
28 Correct 1 ms 4700 KB Output is correct
29 Correct 1 ms 4700 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 1 ms 4700 KB Output is correct
32 Correct 1 ms 4700 KB Output is correct
33 Correct 1 ms 4700 KB Output is correct
34 Correct 1 ms 4700 KB Output is correct
35 Correct 1 ms 4700 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Incorrect 1 ms 4700 KB Output isn't correct
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 1 ms 4700 KB Output is correct
23 Correct 1 ms 4700 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4700 KB Output is correct
26 Correct 1 ms 4700 KB Output is correct
27 Correct 1 ms 4700 KB Output is correct
28 Correct 1 ms 4700 KB Output is correct
29 Correct 1 ms 4700 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 1 ms 4700 KB Output is correct
32 Correct 1 ms 4700 KB Output is correct
33 Correct 1 ms 4700 KB Output is correct
34 Correct 1 ms 4700 KB Output is correct
35 Correct 1 ms 4700 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Incorrect 1 ms 4700 KB Output isn't correct
38 Halted 0 ms 0 KB -