답안 #76998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76998 2018-09-20T00:11:28 Z vex Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
705 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=1;i<n;i++)sort(p[i].begin(),p[i].end());
    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:85:8: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
        if(v==e)
        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1784 KB Output is correct
2 Correct 3 ms 1908 KB Output is correct
3 Correct 3 ms 1932 KB Output is correct
4 Correct 3 ms 1932 KB Output is correct
5 Correct 3 ms 1932 KB Output is correct
6 Correct 3 ms 1932 KB Output is correct
7 Correct 3 ms 1932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1968 KB Output is correct
2 Correct 3 ms 1968 KB Output is correct
3 Correct 3 ms 1968 KB Output is correct
4 Correct 3 ms 1984 KB Output is correct
5 Correct 3 ms 2124 KB Output is correct
6 Correct 3 ms 2124 KB Output is correct
7 Correct 3 ms 2124 KB Output is correct
8 Correct 3 ms 2124 KB Output is correct
9 Correct 3 ms 2124 KB Output is correct
10 Correct 3 ms 2124 KB Output is correct
11 Correct 4 ms 2124 KB Output is correct
12 Correct 13 ms 4224 KB Output is correct
13 Correct 7 ms 4224 KB Output is correct
14 Correct 4 ms 4224 KB Output is correct
15 Correct 4 ms 4224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4224 KB Output is correct
2 Correct 3 ms 4224 KB Output is correct
3 Correct 3 ms 4224 KB Output is correct
4 Correct 3 ms 4224 KB Output is correct
5 Correct 3 ms 4224 KB Output is correct
6 Correct 3 ms 4224 KB Output is correct
7 Correct 3 ms 4224 KB Output is correct
8 Correct 4 ms 4224 KB Output is correct
9 Correct 3 ms 4224 KB Output is correct
10 Correct 3 ms 4224 KB Output is correct
11 Correct 4 ms 4224 KB Output is correct
12 Correct 12 ms 4312 KB Output is correct
13 Correct 7 ms 4312 KB Output is correct
14 Correct 4 ms 4312 KB Output is correct
15 Correct 4 ms 4312 KB Output is correct
16 Correct 4 ms 4312 KB Output is correct
17 Correct 5 ms 4312 KB Output is correct
18 Correct 4 ms 4312 KB Output is correct
19 Correct 4 ms 4312 KB Output is correct
20 Correct 5 ms 4312 KB Output is correct
21 Correct 4 ms 4312 KB Output is correct
22 Correct 3 ms 4312 KB Output is correct
23 Correct 4 ms 4312 KB Output is correct
24 Correct 5 ms 4312 KB Output is correct
25 Correct 4 ms 4312 KB Output is correct
26 Correct 90 ms 35416 KB Output is correct
27 Correct 83 ms 35416 KB Output is correct
28 Correct 5 ms 35416 KB Output is correct
29 Correct 7 ms 35416 KB Output is correct
30 Correct 4 ms 35416 KB Output is correct
31 Correct 5 ms 35416 KB Output is correct
32 Correct 4 ms 35416 KB Output is correct
33 Correct 8 ms 35416 KB Output is correct
34 Correct 8 ms 35416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 35416 KB Output is correct
2 Correct 3 ms 35416 KB Output is correct
3 Correct 3 ms 35416 KB Output is correct
4 Correct 3 ms 35416 KB Output is correct
5 Correct 3 ms 35416 KB Output is correct
6 Correct 3 ms 35416 KB Output is correct
7 Correct 3 ms 35416 KB Output is correct
8 Correct 3 ms 35416 KB Output is correct
9 Correct 3 ms 35416 KB Output is correct
10 Correct 3 ms 35416 KB Output is correct
11 Correct 4 ms 35416 KB Output is correct
12 Correct 11 ms 35416 KB Output is correct
13 Correct 7 ms 35416 KB Output is correct
14 Correct 4 ms 35416 KB Output is correct
15 Correct 4 ms 35416 KB Output is correct
16 Correct 4 ms 35416 KB Output is correct
17 Correct 4 ms 35416 KB Output is correct
18 Correct 4 ms 35416 KB Output is correct
19 Correct 3 ms 35416 KB Output is correct
20 Correct 5 ms 35416 KB Output is correct
21 Correct 4 ms 35416 KB Output is correct
22 Correct 4 ms 35416 KB Output is correct
23 Correct 4 ms 35416 KB Output is correct
24 Correct 5 ms 35416 KB Output is correct
25 Correct 4 ms 35416 KB Output is correct
26 Correct 86 ms 35716 KB Output is correct
27 Correct 81 ms 35716 KB Output is correct
28 Correct 5 ms 35716 KB Output is correct
29 Correct 6 ms 35716 KB Output is correct
30 Correct 4 ms 35716 KB Output is correct
31 Correct 5 ms 35716 KB Output is correct
32 Correct 5 ms 35716 KB Output is correct
33 Correct 10 ms 35716 KB Output is correct
34 Correct 8 ms 35716 KB Output is correct
35 Correct 16 ms 35716 KB Output is correct
36 Correct 5 ms 35716 KB Output is correct
37 Correct 16 ms 35716 KB Output is correct
38 Correct 21 ms 35716 KB Output is correct
39 Correct 23 ms 35716 KB Output is correct
40 Correct 22 ms 35716 KB Output is correct
41 Correct 24 ms 35716 KB Output is correct
42 Runtime error 705 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -