# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
372863 | 2021-03-02T06:06:52 Z | kkk | Awesome Arrowland Adventure (eJOI19_adventure) | C++14 | 3 ms | 1900 KB |
#include<string> #include<vector> #include<iostream> #include<bits/stdc++.h> #define endl '\n' using namespace std; queue<int>v[1000]; char a[100002]; int used[30000]; long long dist[1000003]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n,m,i,j,bru=1,brx=0; cin>>n>>m; char c; for(i=1; i<=n*m; i++) { cin>>a[i]; if(a[i]=='X') brx++; dist[i]=999999999; } v[0].push(1); int is=0; for(i=0; is<2; i++) { while(!v[i].empty()) { int t=v[i].front(); v[i].pop();if(is==2)break; if(t==n*m) is++; if(!used[t]) bru++; used[t]++; if(a[t]=='X') { dist[t]=min(dist[t],i); continue; } if(dist[t]<=i) continue; dist[t]=min(dist[t],i); if(a[t]=='E') { if(t+1<=n*m) v[i].push(t+1); if(t+m<=n*m) v[i+1].push(t+m); if((t-1)%m>0&&(t-1)%m>=1) v[i+2].push(t-1); if((t-m)%m>0 &&(t-m)%m>=1) v[i+3].push(t-m); } if(a[t]=='W') { if(t+1<=n*m) v[i+2].push(t+1); if(t+m<=n*m) v[i+3].push(t+m); if((t-1)%m>0&&(t-1)%m>=1) v[i].push(t-1); if((t-m)%m>0 &&(t-m)%m>=1) v[i+1].push(t-m); } if(a[t]=='S') { if(t+1<=n*m) v[i+3].push(t+1); if(t+m<=n*m) v[i].push(t+m); if((t-1)%m>0&&(t-1)%m>=1) v[i+1].push(t-1); if((t-m)%m>0 &&(t-m)%m>=1) v[i+2].push(t-m); } if(a[t]=='N') { if(t+1<=n*m) v[i+1].push(t+1); if(t+m<=n*m) v[i+2].push(t+m); if((t-1)%m>0 &&(t-1)%m>=1) v[i+3].push(t-1); if((t-m)%m>0 && (t-m)%m>=1) v[i].push(t-m); } } } cout<<dist[n*m]<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1900 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1900 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1900 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1900 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1900 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |