# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22018 | mohammad_kilani | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 389 ms | 113584 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 30001;
bitset<N>vis[N];
int n,m;
vector< vector<int> > g;
int BFS(int s,int e){
queue<pair<int,pair<int,int > > > q;
q.push(make_pair(s,make_pair(g[s][0],0)));
vis[s][0] = true;
while(!q.empty()){
int node = q.front().first;
int jump = q.front().second.first;
int cost = q.front().second.second;
q.pop();
if(node == e)
return cost;
int si = g[node].size();
for(int i=0;i<=si;i++){
int newjump;
if(i == si)
newjump = jump;
else
newjump = g[node][i];
int newnode = node+newjump;
if(newnode >= 0 && newnode < n && !vis[newnode][newjump]){
vis[newnode][newjump] = true;
q.push(make_pair(newnode,make_pair(newjump,cost+1)));
}
newnode = node-newjump;
if(newnode >= 0 && newnode < n && !vis[newnode][newjump]){
vis[newnode][newjump] = true;
q.push(make_pair(newnode,make_pair(newjump,cost+1)));
}
}
}
return -1;
}
int main(){
//freopen("in.txt","r",stdin);
scanf("%d%d",&n,&m);
g.resize(n+2);
int s,e;
for(int i=0;i<m;i++){
int b,p;
scanf("%d%d",&b,&p);
g[b].push_back(p);
if(i == 0){
s = b;
}
if(i == 1)
e = b;
}
cout << BFS(s,e);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |