# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
750272 | 2023-05-29T08:59:44 Z | Yazan_SA | Awesome Arrowland Adventure (eJOI19_adventure) | C++14 | 11 ms | 1620 KB |
#include<bits/stdc++.h> #include <cstdio> #define endl "\n" /*/*(last choice)*/ #define int long long #define all(x) x.begin(), x.end() #define ll long long #define tsts int t; cin>>t; while(t--) #define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); using namespace std; char c[505][505],co[205]; int n, m, mn=1e9; int cs(int x, int y) { if(x>y) return y+4-x; return y-x; } void solve(int i, int j, vector<vector<bool>>vs1, int ac=0) { // cout<<'!'<<endl; cout<<i<<' '<<j<<' '<<ac<<endl; if(i+1==n && j+1==m) { mn=min(mn,ac); return; } vector<vector<bool>>vis; vis=vs1; vis[i][j]=1; if(c[i][j]=='X' || i>=n || j>=m) return; if(!vis[i+1][j]) solve(i+1,j,vis,ac+cs(co[c[i][j]],co['N'])); if(i-1>0) if(!vis[i-1][j]) solve(i-1,j,vis,ac+cs(co[c[i][j]],co['S'])); if(!vis[i][j+1]) solve(i,j+1,vis,ac+cs(co[c[i][j]],co['E'])); if(j-1>0) if(!vis[i][j-1]) solve(i,j-1,vis,ac+cs(co[c[i][j]],co['W'])); } signed main() { // start //freopen("codeblocksinput.txt", "w", stdout); cin>>n>>m; for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin>>c[i][j]; co['N']=0; co['E']=1; co['S']=2; co['W']=3; vector<vector<bool>>vis(505,vector<bool>(505,0)); solve(0,0,vis); cout<<mn; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 852 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 1620 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |