Submission #941204

# Submission time Handle Problem Language Result Execution time Memory
941204 2024-03-08T09:29:48 Z dsyz Maze (JOI23_ho_t3) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll R,C,N;
	cin>>R>>C>>N;
	pair<ll,ll> start, end;
	cin>>start.first>>start.end;
	cin>>end.first>>end.second;
	start.first--, start.second--, end.first--, end.second--;
	char arr[R][C];
	for(ll i = 0;i < R;i++){
		for(ll j = 0;j < C;j++){
			cin>>arr[i][j];
		}
	}
	queue<pair<ll,ll> > q;
	ll dist[R][C][2];
	for(ll i = 0;i < R;i++){
		for(ll j = 0;j < C;j++){
			dist[i][0] = 1e18;
			dist[i][1] = 1e18;	
		}
	}
	q.push({start.first,start.end});
	dist[start.first][start.second][0] = 0;
	while(!q.empty()){
		ll y = q.front().first;
		ll x = q.front().second;
		q.pop();
		for(ll i = -2;i <= 2;i++){
			for(ll j = -2;j <= 2;j++){
				ll a = y + i;
				ll b = x + j;
				if(a < 0 || a >= R || b < 0 || b >= C) continue;
				if(arr[a][b] == '.'){ //white
					if(arr[y][x] == '.'){
						dist[y][x][1] = min(dist[y][x][1],1 + min(dist[a][b][0],dist[a][b][1]));
					}else{
						dist[y][x][1] = min(dist[y][x][1],1 + min(dist[a][b][0],dist[a][b][1]));
						dist[y][x][0] = min(dist[y][x][0],min(dist[a][b][0],dist[a][b][1]));
					}
				}else{ //black
					if(arr[y][x] == '.'){
						dist[y][x][1] = min(dist[y][x][1],1 + dist[a][b][1]);
					}else{
						dist[y][x][1] = min(dist[y][x][1],1 + dist[a][b][1]);
						dist[y][x][0] = min(dist[y][x][0],dist[a][b][1]);
					}
				}
			}
		}
	}
	
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:26: error: 'struct std::pair<long long int, long long int>' has no member named 'end'
   10 |  cin>>start.first>>start.end;
      |                          ^~~
Main.cpp:23:15: error: incompatible types in assignment of 'double' to 'll [2]' {aka 'long long int [2]'}
   23 |    dist[i][0] = 1e18;
      |    ~~~~~~~~~~~^~~~~~
Main.cpp:24:15: error: incompatible types in assignment of 'double' to 'll [2]' {aka 'long long int [2]'}
   24 |    dist[i][1] = 1e18;
      |    ~~~~~~~~~~~^~~~~~
Main.cpp:27:28: error: 'struct std::pair<long long int, long long int>' has no member named 'end'
   27 |  q.push({start.first,start.end});
      |                            ^~~
Main.cpp:27:32: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
   27 |  q.push({start.first,start.end});
      |                                ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~