Submission #776251

# Submission time Handle Problem Language Result Execution time Memory
776251 2023-07-07T13:51:53 Z vjudge1 Awesome Arrowland Adventure (eJOI19_adventure) C++17
100 / 100
75 ms 7612 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define pb push_back
#define p push
#define f first
#define s second
ll int fark[5][5];
int main(){
	lalala;
	int n,m;
	cin>>n>>m;
	ll int uzak[n][m],arr[n][m];
	for(int i=0;i<n;i++){
		string str;cin>>str;
		for(int j=0;j<str.size();j++){

			uzak[i][j]=-1;
			if(str[j]=='E')arr[i][j]=1;
			if(str[j]=='S')arr[i][j]=2;
			if(str[j]=='W')arr[i][j]=3;
			if(str[j]=='N')arr[i][j]=4;
			if(str[j]=='X')arr[i][j]=0;

		}
	}
	fark[0][1]=fark[0][2]=fark[0][3]=fark[0][4]=1000000000000000000;
	fark[1][0]=fark[2][0]=fark[3][0]=fark[4][0]=1000000000000000000;
	fark[1][2]=1;fark[1][3]=2;fark[1][4]=3;
	fark[2][1]=3;fark[2][3]=1;fark[2][4]=2;
	fark[3][1]=2;fark[3][2]=3;fark[3][4]=1;
	fark[4][1]=1;;fark[4][2]=2;fark[4][3]=3;
	priority_queue<pair<int,pair<int,int>>> pq;
	pq.p({0,{0,0}});
	while(pq.size()){
		ll int deg=-pq.top().f, x=pq.top().s.f, y=pq.top().s.s;
		pq.pop();
		if(uzak[x][y]!=-1)continue;
		uzak[x][y]=deg;
		int kim=arr[x][y];
		if(kim==0)continue;
		if(x!=0&&uzak[x-1][y]==-1)pq.p({-(deg+fark[kim][4]),{x-1,y}});
		
		if(x!=n-1&&uzak[x+1][y]==-1)pq.p({-(deg+fark[kim][2]),{x+1,y}});
		
		if(y!=0&&uzak[x][y-1]==-1)pq.p({-(deg+fark[kim][3]),{x,y-1}});

		if(y!=m-1&&uzak[x][y+1]==-1)pq.p({-(deg+fark[kim][1]),{x,y+1}});
	}
	cout<<uzak[n-1][m-1]<<endl;

}

Compilation message

adventure.cpp: In function 'int main()':
adventure.cpp:18:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(int j=0;j<str.size();j++){
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 224 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 224 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 5 ms 596 KB Output is correct
36 Correct 1 ms 316 KB Output is correct
37 Correct 6 ms 716 KB Output is correct
38 Correct 1 ms 976 KB Output is correct
39 Correct 61 ms 4512 KB Output is correct
40 Correct 58 ms 4512 KB Output is correct
41 Correct 5 ms 4436 KB Output is correct
42 Correct 58 ms 4512 KB Output is correct
43 Correct 75 ms 7612 KB Output is correct
44 Correct 4 ms 4428 KB Output is correct