Submission #463683

# Submission time Handle Problem Language Result Execution time Memory
463683 2021-08-11T13:39:49 Z AdamGS Awesome Arrowland Adventure (eJOI19_adventure) C++14
100 / 100
117 ms 21624 KB
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") 
#pragma GCC option("arch=native","tune=native","no-zero-upper") 
#pragma GCC target("avx2","popcnt","rdrnd","bmi2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=507, INF=1e9+7;
string T[LIM];
int odl[LIM*LIM];
vector<pair<int,int>>V[LIM*LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	rep(i, n) cin >> T[i];
	rep(i, n) rep(j, m) if(T[i][j]!='X')  {
		int ile=0;
		if(T[i][j]=='E') ile=3;
		if(T[i][j]=='S') ile=2;
		if(T[i][j]=='W') ile=1;
		if(i>0) V[i*m+j].pb({(i-1)*m+j, ile});
		ile=(ile+1)%4;
		if(j<m-1) V[i*m+j].pb({i*m+j+1, ile});
		ile=(ile+1)%4;
		if(i<n-1) V[i*m+j].pb({(i+1)*m+j, ile});
		ile=(ile+1)%4;
		if(j>0) V[i*m+j].pb({i*m+j-1, ile});
	}
	rep(i, n*m) odl[i]=INF;
	priority_queue<pair<int,int>>q;
	q.push({0, 0});
	while(!q.empty()) {
		int p=q.top().nd, o=-q.top().st; q.pop();
		if(odl[p]<o) continue;
		odl[p]=o;
		for(auto i : V[p]) if(odl[i.st]>odl[p]+i.nd) {
			q.push({-odl[p]-i.nd, i.st});
		}
	}
	cout << (odl[n*m-1]==INF?-1:odl[n*m-1]) << '\n';
}

Compilation message

adventure.cpp:2: warning: ignoring '#pragma GCC option' [-Wunknown-pragmas]
    2 | #pragma GCC option("arch=native","tune=native","no-zero-upper")
      |
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6348 KB Output is correct
2 Correct 4 ms 6348 KB Output is correct
3 Correct 4 ms 6348 KB Output is correct
4 Correct 4 ms 6348 KB Output is correct
5 Correct 4 ms 6376 KB Output is correct
6 Correct 4 ms 6348 KB Output is correct
7 Correct 4 ms 6348 KB Output is correct
8 Correct 4 ms 6368 KB Output is correct
9 Correct 4 ms 6348 KB Output is correct
10 Correct 4 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6348 KB Output is correct
2 Correct 4 ms 6348 KB Output is correct
3 Correct 4 ms 6348 KB Output is correct
4 Correct 4 ms 6348 KB Output is correct
5 Correct 4 ms 6376 KB Output is correct
6 Correct 4 ms 6348 KB Output is correct
7 Correct 4 ms 6348 KB Output is correct
8 Correct 4 ms 6368 KB Output is correct
9 Correct 4 ms 6348 KB Output is correct
10 Correct 4 ms 6348 KB Output is correct
11 Correct 5 ms 6272 KB Output is correct
12 Correct 5 ms 6348 KB Output is correct
13 Correct 5 ms 6348 KB Output is correct
14 Correct 4 ms 6348 KB Output is correct
15 Correct 4 ms 6376 KB Output is correct
16 Correct 4 ms 6348 KB Output is correct
17 Correct 5 ms 6348 KB Output is correct
18 Correct 4 ms 6348 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 4 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6348 KB Output is correct
2 Correct 4 ms 6348 KB Output is correct
3 Correct 4 ms 6348 KB Output is correct
4 Correct 4 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6348 KB Output is correct
2 Correct 5 ms 6348 KB Output is correct
3 Correct 5 ms 6348 KB Output is correct
4 Correct 5 ms 6348 KB Output is correct
5 Correct 5 ms 6416 KB Output is correct
6 Correct 5 ms 6376 KB Output is correct
7 Correct 4 ms 6348 KB Output is correct
8 Correct 4 ms 6348 KB Output is correct
9 Correct 4 ms 6348 KB Output is correct
10 Correct 5 ms 6348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6348 KB Output is correct
2 Correct 4 ms 6348 KB Output is correct
3 Correct 4 ms 6348 KB Output is correct
4 Correct 4 ms 6348 KB Output is correct
5 Correct 4 ms 6376 KB Output is correct
6 Correct 4 ms 6348 KB Output is correct
7 Correct 4 ms 6348 KB Output is correct
8 Correct 4 ms 6368 KB Output is correct
9 Correct 4 ms 6348 KB Output is correct
10 Correct 4 ms 6348 KB Output is correct
11 Correct 5 ms 6272 KB Output is correct
12 Correct 5 ms 6348 KB Output is correct
13 Correct 5 ms 6348 KB Output is correct
14 Correct 4 ms 6348 KB Output is correct
15 Correct 4 ms 6376 KB Output is correct
16 Correct 4 ms 6348 KB Output is correct
17 Correct 5 ms 6348 KB Output is correct
18 Correct 4 ms 6348 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 4 ms 6348 KB Output is correct
21 Correct 4 ms 6348 KB Output is correct
22 Correct 4 ms 6348 KB Output is correct
23 Correct 4 ms 6348 KB Output is correct
24 Correct 4 ms 6348 KB Output is correct
25 Correct 5 ms 6348 KB Output is correct
26 Correct 5 ms 6348 KB Output is correct
27 Correct 5 ms 6348 KB Output is correct
28 Correct 5 ms 6348 KB Output is correct
29 Correct 5 ms 6416 KB Output is correct
30 Correct 5 ms 6376 KB Output is correct
31 Correct 4 ms 6348 KB Output is correct
32 Correct 4 ms 6348 KB Output is correct
33 Correct 4 ms 6348 KB Output is correct
34 Correct 5 ms 6348 KB Output is correct
35 Correct 13 ms 7372 KB Output is correct
36 Correct 5 ms 6376 KB Output is correct
37 Correct 14 ms 7532 KB Output is correct
38 Correct 10 ms 8140 KB Output is correct
39 Correct 106 ms 17372 KB Output is correct
40 Correct 107 ms 17252 KB Output is correct
41 Correct 39 ms 17172 KB Output is correct
42 Correct 107 ms 17232 KB Output is correct
43 Correct 117 ms 21624 KB Output is correct
44 Correct 37 ms 17220 KB Output is correct