Submission #23598

# Submission time Handle Problem Language Result Execution time Memory
23598 2017-05-12T20:47:28 Z repeating Jakarta Skyscrapers (APIO15_skyscraper) C++11
22 / 100
1000 ms 125052 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 long long
#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]});
    ll dis,ver,node,d;
    ll res=-1;
    W(!pq.empty()){
        dis=pq.top().F,ver=pq.top().S;
        pq.pop();
        if(ver==pos)
            if(res==-1||res>dis)
                res=dis;
        if(vis[ver])C;
        vis[ver]=1;
        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 res;
}
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=0;k<m;q++,k+=j){
                adj[i].pb({k,q});
            }
            for(int k=i,q=0;k>=0;q++,k-=j){
                adj[i].pb({k,q});
            }
        }
    }
    cout<<dijkstra();
}

Compilation message

skyscraper.cpp: In function 'long long int dijkstra()':
skyscraper.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adj[ver].SI;i++){
                      ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11752 KB Output is correct
2 Correct 0 ms 11752 KB Output is correct
3 Correct 0 ms 11752 KB Output is correct
4 Correct 0 ms 11752 KB Output is correct
5 Correct 0 ms 11752 KB Output is correct
6 Correct 0 ms 11752 KB Output is correct
7 Correct 0 ms 11752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11752 KB Output is correct
2 Correct 0 ms 11752 KB Output is correct
3 Correct 0 ms 11752 KB Output is correct
4 Correct 0 ms 11752 KB Output is correct
5 Correct 0 ms 11752 KB Output is correct
6 Correct 0 ms 11752 KB Output is correct
7 Correct 0 ms 11752 KB Output is correct
8 Correct 0 ms 11752 KB Output is correct
9 Correct 0 ms 11752 KB Output is correct
10 Correct 0 ms 11884 KB Output is correct
11 Correct 3 ms 12208 KB Output is correct
12 Correct 0 ms 11752 KB Output is correct
13 Correct 3 ms 12156 KB Output is correct
14 Correct 3 ms 12148 KB Output is correct
15 Correct 3 ms 12148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11752 KB Output is correct
2 Correct 0 ms 11752 KB Output is correct
3 Correct 0 ms 11752 KB Output is correct
4 Correct 0 ms 11752 KB Output is correct
5 Correct 0 ms 11752 KB Output is correct
6 Correct 0 ms 11752 KB Output is correct
7 Correct 0 ms 11752 KB Output is correct
8 Correct 0 ms 11752 KB Output is correct
9 Correct 0 ms 11752 KB Output is correct
10 Correct 0 ms 11884 KB Output is correct
11 Correct 3 ms 12208 KB Output is correct
12 Correct 0 ms 11752 KB Output is correct
13 Correct 3 ms 12156 KB Output is correct
14 Correct 3 ms 12148 KB Output is correct
15 Correct 0 ms 12148 KB Output is correct
16 Correct 0 ms 11884 KB Output is correct
17 Correct 3 ms 13156 KB Output is correct
18 Correct 6 ms 12016 KB Output is correct
19 Correct 6 ms 11884 KB Output is correct
20 Execution timed out 1000 ms 125052 KB Execution timed out
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11752 KB Output is correct
2 Correct 0 ms 11752 KB Output is correct
3 Correct 0 ms 11752 KB Output is correct
4 Correct 0 ms 11752 KB Output is correct
5 Correct 0 ms 11752 KB Output is correct
6 Correct 0 ms 11752 KB Output is correct
7 Correct 0 ms 11752 KB Output is correct
8 Correct 0 ms 11752 KB Output is correct
9 Correct 0 ms 11752 KB Output is correct
10 Correct 0 ms 11884 KB Output is correct
11 Correct 3 ms 12208 KB Output is correct
12 Correct 0 ms 11752 KB Output is correct
13 Correct 3 ms 12156 KB Output is correct
14 Correct 3 ms 12148 KB Output is correct
15 Correct 3 ms 12148 KB Output is correct
16 Correct 0 ms 11884 KB Output is correct
17 Correct 3 ms 13156 KB Output is correct
18 Correct 3 ms 12016 KB Output is correct
19 Correct 3 ms 11884 KB Output is correct
20 Execution timed out 1000 ms 125052 KB Execution timed out
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11752 KB Output is correct
2 Correct 0 ms 11752 KB Output is correct
3 Correct 0 ms 11752 KB Output is correct
4 Correct 0 ms 11752 KB Output is correct
5 Correct 0 ms 11752 KB Output is correct
6 Correct 0 ms 11752 KB Output is correct
7 Correct 0 ms 11752 KB Output is correct
8 Correct 0 ms 11752 KB Output is correct
9 Correct 0 ms 11752 KB Output is correct
10 Correct 0 ms 11884 KB Output is correct
11 Correct 3 ms 12208 KB Output is correct
12 Correct 0 ms 11752 KB Output is correct
13 Correct 3 ms 12156 KB Output is correct
14 Correct 0 ms 12148 KB Output is correct
15 Correct 0 ms 12148 KB Output is correct
16 Correct 0 ms 11884 KB Output is correct
17 Correct 6 ms 13156 KB Output is correct
18 Correct 3 ms 12016 KB Output is correct
19 Correct 3 ms 11884 KB Output is correct
20 Execution timed out 1000 ms 125052 KB Execution timed out
21 Halted 0 ms 0 KB -