# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
207097 | Sa1loum | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 487 ms | 262148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size()
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)3e4+10;
int n,m,b[MAX],p[MAX],vis[MAX];
vector <pair<int,int> > v[MAX];
int main()
{
scanf("%d%d",&n,&m);
int s,e;
for (int i=0;i<m;i++) {
scanf("%d%d",&b[i],&p[i]);
int d=0;
if (i==0) s=b[i];
if (i==1) e=b[i];
for (int j=b[i],k=b[i];;j+=p[i],k-=p[i]) {
bool flag=0;
if (0<=j && j<n) {
flag=1;
if (j!=b[i]) {
v[b[i]].push_back({j,d});
}
}
if (0<=k && k<n) {
flag=1;
if (k!=b[i]) {
v[b[i]].push_back({k,d});
}
}
d++;
if (!flag) break;
}
}
priority_queue <pair<int,int>> pq;
pq.push({0,s});
while (!pq.empty()) {
int x=pq.top().S;
int w=-pq.top().F;
pq.pop();
if (vis[x]) continue;
vis[x]=1;
if (x==e) {printf("%d\n",w); return 0;}
for (auto it:v[x]) {
if (vis[it.F]) continue;
pq.push({-w-it.S,it.F});
}
}
puts("-1\n");
}
컴파일 시 표준 에러 (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... |