답안 #23591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23591 2017-05-12T19:56:38 Z repeating Jakarta Skyscrapers (APIO15_skyscraper) C++11
0 / 100
0 ms 11732 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll int
#define pll pair<ll,ll>
#define SF(x) scanf("%I64d",&x)

using namespace std;
const long long INF = 2e9;
long long MOD = 1e9+7;
ll n,m;
ll a[2222],b[2222];
vector<pll> adj[2222];
bool vis[2222];
priority_queue< pll , vector<pll> , greater<pll> > pq;
ll pos;
bool bol[2222][2222];
ll dijkstra(){
    pq.P({0,a[0]});
    W(!pq.empty()){
        ll dis=pq.top().F,ver=pq.top().S;
        pq.pop();
        if(ver==pos)R dis;
        if(vis[ver])C;
        vis[ver]=1;
        ll node,d;
        for(int i=0;i<adj[ver].SI;i++){
            node=adj[ver][i].F;
            d=dis+adj[ver][i].S;
            pq.P({d,node});
        }
    }
    R -1;
}
bool vs[2222][2222];
int main(){
    cin>>m>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(b[i]<=2000)bol[a[i]][b[i]]=1;
    }
    pos=a[1];
    for(int i=0;i<m;i++){
        for(int j=1;j<=2000;j++){
            if(!bol[i][j])C;
            for(int k=i,q=1;k<m;q++,k+=j){
                adj[i].pb({k,q});
            }
            for(int k=i,q=1;k>=0;q++,k-=j){
                adj[i].pb({k,q});
            }
        }
    }
    cout<<dijkstra();
}

Compilation message

skyscraper.cpp: In function 'int dijkstra()':
skyscraper.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adj[ver].SI;i++){
                      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 11732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 11732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 11732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 11732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 11732 KB Output isn't correct
2 Halted 0 ms 0 KB -