Submission #1055576

# Submission time Handle Problem Language Result Execution time Memory
1055576 2024-08-12T22:21:12 Z _rain_ Maze (JOI23_ho_t3) C++14
0 / 100
2 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define all(datastructure) datastructure.begin(),datastructure.end()
#define find(_vector , _data) upper_bound(_vector.begin(),_vector.end(),_data) - _vector.begin()

int numrow , numcol , k;
int sourcex , sourcey;
int sinkx , sinky;

struct _D
{
	int x , y;
	int stepx , stepy;
};
queue<_D> freezone , banzone;
const int dx[] = {0 , 0 , 1 , -1};
const int dy[] = {1 , -1 , 0 , 0};
bool Zone(int x , int y)
{
	return x > 0 && x <= numrow && y > 0 && y <= numcol;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	freopen("text.inp","r",stdin);
	freopen("text.out","w",stdout);
	cin >> numrow >> numcol >> k;
	cin >> sourcex >> sourcey;
	cin >> sinkx >> sinky;
	vector<vector<char>> a(numrow+2,vector<char>(numcol+2));
	vector<vector<int>> d(numrow+2,vector<int>(numcol+2,-1));
	for (int i = 1; i <= numrow; ++i)
		for (int j = 1; j <= numcol; ++j)
			cin >> a[i][j];
	if (a[sourcex][sourcey] == '.') 
	{
		d[sourcex][sourcey] = 0;
		freezone.push({sourcex,sourcey,0,0});
	}
		else 
		{
			d[sourcex][sourcey] = 1;
			banzone.push({sourcex,sourcey,k,k});
		}
	while (freezone.size() || banzone.size())
	{
		while (banzone.size())
		{
			_D node = banzone.front(); banzone.pop();
			
			for (int i = 0; i < 4; ++i)
			{
				int u = node.x + dx[i];
				int v = node.y + dy[i];
				int remx = node.stepx - abs(dx[i]);
				int remy = node.stepy - abs(dy[i]);
				if ((node.stepx&node.stepy) && Zone(u,v) && d[u][v] == -1)
				{
					d[u][v] = d[node.x][node.y];
					if (remx && remy) banzone.push({u , v , remx , remy});
					else freezone.push({u , v , 0 , 0});
				}
			}
		}
		
		while (freezone.size())
		{
			_D node = freezone.front(); freezone.pop();
			
			for (int i = 0; i < 4; ++i)
			{
				int u = node.x + dx[i];
				int v = node.y + dy[i];
				if (Zone(u,v) && d[u][v] == -1)
				{
					if (a[u][v] == '#') 
					{
						banzone.push({u , v , k - 1 , k - 1});
						d[u][v] = d[node.x][node.y] + 1;
					}
					else 
					{
						freezone.push({u , v , 0 , 0});
						d[u][v] = d[node.x][node.y];
					}
				}
			}
		}
	}
	cout << d[sinkx][sourcex];	
	return 0;

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  freopen("text.inp","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:29:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  freopen("text.out","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -