| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 21968 | Hiasat | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 0 ms | 21812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
const int MOD = 1e9 + 7;
const ll oo = 1e15;
typedef long long ll;
int n , m;
pii d[2010];
bool vis[2010][2010];
int cost[2010][2010];
vector<int> dogs[2010];
int main() {
//freopen("input.txt","r",stdin);
scanf("%d%d",&n,&m);
for (int i = 0; i < m; ++i){
scanf("%d%d",&d[i].first,&d[i].second);
dogs[d[i].first].push_back(i);
}
deque<pii> q;
cost[d[0].first][0] = 0;
vis[d[0].first][0] = 1;
q.push_front(make_pair(d[0].first,0));
while(!q.empty()){
pii src = q.front();
if(src.first == d[1].first){
printf("%d\n", cost[src.first][src.second]);
return 0;
}
q.pop_back();
for (int i = 0; i < dogs[src.first].size(); ++i){
int nw = dogs[src.first][i];
if(vis[src.first][nw])
continue;
vis[src.first][nw] = 1;
cost[src.first][nw] = cost[src.first][src.second];
q.push_front(make_pair(src.first,nw));
}
for(int i = -1 ; i <= 1 ; i+= 2){
int nw = src.first + d[src.second].second * i;
if(nw < 0 || nw >= n)
continue;
if(vis[nw][src.second])
continue;
vis[nw][src.second]=1;
cost[nw][src.second] = 1 + cost[src.first][src.second];
q.push_back(make_pair(nw,src.second));
}
}
puts("-1");
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... | ||||
