Submission #76997

# Submission time Handle Problem Language Result Execution time Memory
76997 2018-09-20T00:04:32 Z vex Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
721 ms 263168 KB
#include <bits/stdc++.h>
#define maxn 30005
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
 
int n,m;
pii dg[maxn];
vector<int>p[maxn];

vector<pii>adj[maxn];
priority_queue<pii>pq;
int dis[maxn];
bool bio[maxn];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    cin>>n>>m;
    int s;
    int e;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        dg[i].f=x;
        dg[i].s=y;
        if(i==0)s=x;
        if(i==1)e=x;
        p[y].push_back(x);
    }
    for(int i=0;i<m;i++)
    {
	int pp=0;
      	int sz=p[dg[i].s].size();
      	while(p[dg[i].s][pp]!=dg[i].f)pp++;

	int up=pp+1;
      	for(int j=dg[i].f+dg[i].s;j<n;j+=dg[i].s)
        {
          	while(up<sz && p[dg[i].s][up]<j)up++;
          	adj[dg[i].f].push_back({j,(j-dg[i].f)/dg[i].s});
          	if(up<sz && p[dg[i].s][up]==j)break; 
        }
      	
      	pp--;
      	for(int j=dg[i].f-dg[i].s;j>=0;j-=dg[i].s)
        {
          	while(pp>=0 && p[dg[i].s][pp]>j)pp--;
            adj[dg[i].f].push_back({j,(dg[i].f-j)/dg[i].s});
            if(pp>=0 && p[dg[i].s][pp]==j)break; 
        }
    }
    
    /*for(int i=0;i<n;i++)
    {
    	cout<<i<<"   ";
    	for(auto x:adj[i])cout<<x.f<<","<<x.s<<" ";
    	cout<<endl;
    }*/
 
    if(e==s)
    {
        cout<<"0"<<endl;
        return 0;
    }
 
    for(int i=0;i<n;i++)
    {
        dis[i]=maxn*maxn+55;
        bio[i]=false;
    }
    pq.push({0,s});
    dis[s]=0;
 
    while(!pq.empty())
    {
        int v=pq.top().second;
        pq.pop();
      	if(v==e)
        {
          cout<<dis[e]<<endl;
          return 0;
        }
        if(bio[v])continue;
        bio[v]=true;
 
        for(auto x:adj[v])
        {
    		int u=x.f;
          	int w=x.s;
          	if(dis[u]>dis[v]+w)
            {
              	dis[u]=dis[v]+w;
              	pq.push({-dis[u],u});
            }
        }
    }
 
    cout<<"-1"<<endl;
    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:84:8: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
        if(v==e)
        ^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1784 KB Output is correct
2 Correct 3 ms 1788 KB Output is correct
3 Correct 3 ms 1992 KB Output is correct
4 Correct 3 ms 1996 KB Output is correct
5 Correct 3 ms 1996 KB Output is correct
6 Correct 3 ms 1996 KB Output is correct
7 Correct 3 ms 2000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2028 KB Output is correct
2 Correct 3 ms 2028 KB Output is correct
3 Correct 3 ms 2028 KB Output is correct
4 Correct 3 ms 2028 KB Output is correct
5 Correct 3 ms 2140 KB Output is correct
6 Correct 3 ms 2140 KB Output is correct
7 Correct 3 ms 2140 KB Output is correct
8 Correct 3 ms 2140 KB Output is correct
9 Correct 4 ms 2140 KB Output is correct
10 Correct 3 ms 2140 KB Output is correct
11 Correct 4 ms 2184 KB Output is correct
12 Correct 11 ms 4240 KB Output is correct
13 Correct 8 ms 4240 KB Output is correct
14 Correct 4 ms 4240 KB Output is correct
15 Correct 4 ms 4240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4240 KB Output is correct
2 Correct 3 ms 4240 KB Output is correct
3 Correct 3 ms 4240 KB Output is correct
4 Correct 3 ms 4240 KB Output is correct
5 Correct 3 ms 4240 KB Output is correct
6 Correct 3 ms 4240 KB Output is correct
7 Correct 3 ms 4240 KB Output is correct
8 Correct 3 ms 4240 KB Output is correct
9 Correct 4 ms 4240 KB Output is correct
10 Correct 3 ms 4240 KB Output is correct
11 Correct 4 ms 4240 KB Output is correct
12 Correct 12 ms 4308 KB Output is correct
13 Correct 8 ms 4308 KB Output is correct
14 Correct 4 ms 4308 KB Output is correct
15 Correct 4 ms 4308 KB Output is correct
16 Correct 4 ms 4308 KB Output is correct
17 Correct 5 ms 4308 KB Output is correct
18 Correct 4 ms 4308 KB Output is correct
19 Correct 3 ms 4308 KB Output is correct
20 Correct 55 ms 23576 KB Output is correct
21 Correct 3 ms 23576 KB Output is correct
22 Correct 4 ms 23576 KB Output is correct
23 Correct 4 ms 23576 KB Output is correct
24 Correct 5 ms 23576 KB Output is correct
25 Correct 4 ms 23576 KB Output is correct
26 Correct 98 ms 35448 KB Output is correct
27 Correct 83 ms 35448 KB Output is correct
28 Correct 5 ms 35448 KB Output is correct
29 Correct 6 ms 35448 KB Output is correct
30 Correct 4 ms 35448 KB Output is correct
31 Correct 5 ms 35448 KB Output is correct
32 Correct 4 ms 35448 KB Output is correct
33 Correct 8 ms 35448 KB Output is correct
34 Correct 8 ms 35448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 35448 KB Output is correct
2 Correct 3 ms 35448 KB Output is correct
3 Correct 3 ms 35448 KB Output is correct
4 Correct 3 ms 35448 KB Output is correct
5 Correct 3 ms 35448 KB Output is correct
6 Correct 3 ms 35448 KB Output is correct
7 Correct 3 ms 35448 KB Output is correct
8 Correct 3 ms 35448 KB Output is correct
9 Correct 3 ms 35448 KB Output is correct
10 Correct 3 ms 35448 KB Output is correct
11 Correct 4 ms 35448 KB Output is correct
12 Correct 12 ms 35448 KB Output is correct
13 Correct 8 ms 35448 KB Output is correct
14 Correct 4 ms 35448 KB Output is correct
15 Correct 4 ms 35448 KB Output is correct
16 Correct 4 ms 35448 KB Output is correct
17 Correct 5 ms 35448 KB Output is correct
18 Correct 4 ms 35448 KB Output is correct
19 Correct 4 ms 35448 KB Output is correct
20 Correct 53 ms 35448 KB Output is correct
21 Correct 5 ms 35448 KB Output is correct
22 Correct 4 ms 35448 KB Output is correct
23 Correct 4 ms 35448 KB Output is correct
24 Correct 5 ms 35448 KB Output is correct
25 Correct 5 ms 35448 KB Output is correct
26 Correct 85 ms 35756 KB Output is correct
27 Correct 82 ms 35756 KB Output is correct
28 Correct 6 ms 35756 KB Output is correct
29 Correct 6 ms 35756 KB Output is correct
30 Correct 4 ms 35756 KB Output is correct
31 Correct 5 ms 35756 KB Output is correct
32 Correct 4 ms 35756 KB Output is correct
33 Correct 7 ms 35756 KB Output is correct
34 Correct 7 ms 35756 KB Output is correct
35 Correct 18 ms 35756 KB Output is correct
36 Correct 5 ms 35756 KB Output is correct
37 Correct 18 ms 35756 KB Output is correct
38 Correct 22 ms 35756 KB Output is correct
39 Correct 19 ms 35756 KB Output is correct
40 Correct 19 ms 35756 KB Output is correct
41 Correct 22 ms 35756 KB Output is correct
42 Runtime error 721 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -