Submission #72744

# Submission time Handle Problem Language Result Execution time Memory
72744 2018-08-26T22:01:38 Z Pajaraja Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
1000 ms 263168 KB
#include <bits/stdc++.h>
#define MAXN 30007
using namespace std;
vector<int> g[MAXN],w[MAXN],a[MAXN];
set<int> v[MAXN];
bool vi[MAXN];
int dist[MAXN],en;
void dijkstra(int s)
{
	priority_queue<pair<int,int> > pq;
	pq.push(make_pair(0,s));
	while(!pq.empty())
	{
		int u=pq.top().second,d=-pq.top().first;
		pq.pop();
		if(vi[u]) continue;
		dist[u]=d;
		vi[u]=true;
		if(u==en) return;
		for(int i=0;i<g[u].size();i++) if(!vi[g[u][i]]) pq.push(make_pair(-d-w[u][i],g[u][i]));
	}
}
/*bool binarna(int l,int r,int k,int val)
{
	if(r<l) return false;
	int s=(l+r)/2;
	if(v[k][s]==val) return true;
	if(val<v[k][s]) return binarna(l,s-1,k,val);
	return binarna(s+1,r,k,val);
}*/
int main()
{
	int n,m,st,t1,t2;
	scanf("%d%d",&n,&m);
	scanf("%d%d%d%d",&st,&t1,&en,&t2);
	v[st].insert(t1);
	v[en].insert(t2);
	a[st].push_back(t1);
	a[en].push_back(t2);
	for(int i=0;i<m-2;i++)
	{
		scanf("%d%d",&t1,&t2);
		v[t1].insert(t2);
		a[t1].push_back(t2);
	}
	for(int i=0;i<n;i++) sort(a[i].begin(),a[i].end());
	for(int i=0;i<n;i++)
	{
		for(int j=a[i].size()-1;j>=0;j--)
		{
			int t=a[i][j],cur=i+t;
			while(cur<n)
			{
				g[i].push_back(cur);
				w[i].push_back((cur-i)/t);
				if(v[cur].find(t)!=v[cur].end()) break;
				cur+=t;
			} 
			cur=i-t;
			while(cur>=0)
			{
				g[i].push_back(cur);
				w[i].push_back((i-cur)/t);
				if(v[cur].find(t)!=v[cur].end()) break;
				cur-=t;
			}
		}
	}
	dijkstra(st);
	if(!vi[en]) dist[en]=-1;
	printf("%d",dist[en]);
}

Compilation message

skyscraper.cpp: In function 'void dijkstra(int)':
skyscraper.cpp:20:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<g[u].size();i++) if(!vi[g[u][i]]) pq.push(make_pair(-d-w[u][i],g[u][i]));
               ~^~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d",&st,&t1,&en,&t2);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&t1,&t2);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3832 KB Output is correct
2 Correct 6 ms 3944 KB Output is correct
3 Correct 5 ms 4000 KB Output is correct
4 Correct 6 ms 4000 KB Output is correct
5 Correct 5 ms 4000 KB Output is correct
6 Correct 5 ms 4000 KB Output is correct
7 Correct 5 ms 4028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4028 KB Output is correct
2 Correct 5 ms 4028 KB Output is correct
3 Correct 5 ms 4028 KB Output is correct
4 Correct 5 ms 4028 KB Output is correct
5 Correct 5 ms 4028 KB Output is correct
6 Correct 5 ms 4052 KB Output is correct
7 Correct 6 ms 4076 KB Output is correct
8 Correct 4 ms 4204 KB Output is correct
9 Correct 6 ms 4204 KB Output is correct
10 Correct 6 ms 4204 KB Output is correct
11 Correct 6 ms 4220 KB Output is correct
12 Correct 13 ms 5792 KB Output is correct
13 Correct 6 ms 5792 KB Output is correct
14 Correct 7 ms 5792 KB Output is correct
15 Correct 10 ms 5792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5792 KB Output is correct
2 Correct 6 ms 5792 KB Output is correct
3 Correct 6 ms 5792 KB Output is correct
4 Correct 5 ms 5792 KB Output is correct
5 Correct 5 ms 5792 KB Output is correct
6 Correct 6 ms 5792 KB Output is correct
7 Correct 6 ms 5792 KB Output is correct
8 Correct 6 ms 5792 KB Output is correct
9 Correct 5 ms 5792 KB Output is correct
10 Correct 6 ms 5792 KB Output is correct
11 Correct 6 ms 5792 KB Output is correct
12 Correct 11 ms 5792 KB Output is correct
13 Correct 6 ms 5792 KB Output is correct
14 Correct 7 ms 5792 KB Output is correct
15 Correct 7 ms 5792 KB Output is correct
16 Correct 6 ms 5792 KB Output is correct
17 Correct 7 ms 5792 KB Output is correct
18 Correct 6 ms 5792 KB Output is correct
19 Correct 5 ms 5792 KB Output is correct
20 Correct 6 ms 5792 KB Output is correct
21 Correct 6 ms 5792 KB Output is correct
22 Correct 5 ms 5792 KB Output is correct
23 Correct 5 ms 5792 KB Output is correct
24 Correct 7 ms 5792 KB Output is correct
25 Correct 6 ms 5792 KB Output is correct
26 Correct 87 ms 32524 KB Output is correct
27 Correct 97 ms 32524 KB Output is correct
28 Correct 7 ms 32524 KB Output is correct
29 Correct 18 ms 32524 KB Output is correct
30 Correct 9 ms 32524 KB Output is correct
31 Correct 10 ms 32524 KB Output is correct
32 Correct 7 ms 32524 KB Output is correct
33 Correct 32 ms 32524 KB Output is correct
34 Correct 22 ms 32524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 32524 KB Output is correct
2 Correct 7 ms 32524 KB Output is correct
3 Correct 4 ms 32524 KB Output is correct
4 Correct 6 ms 32524 KB Output is correct
5 Correct 5 ms 32524 KB Output is correct
6 Correct 5 ms 32524 KB Output is correct
7 Correct 5 ms 32524 KB Output is correct
8 Correct 5 ms 32524 KB Output is correct
9 Correct 5 ms 32524 KB Output is correct
10 Correct 6 ms 32524 KB Output is correct
11 Correct 6 ms 32524 KB Output is correct
12 Correct 12 ms 32524 KB Output is correct
13 Correct 7 ms 32524 KB Output is correct
14 Correct 6 ms 32524 KB Output is correct
15 Correct 5 ms 32524 KB Output is correct
16 Correct 7 ms 32524 KB Output is correct
17 Correct 8 ms 32524 KB Output is correct
18 Correct 6 ms 32524 KB Output is correct
19 Correct 7 ms 32524 KB Output is correct
20 Correct 7 ms 32524 KB Output is correct
21 Correct 7 ms 32524 KB Output is correct
22 Correct 7 ms 32524 KB Output is correct
23 Correct 6 ms 32524 KB Output is correct
24 Correct 10 ms 32524 KB Output is correct
25 Correct 6 ms 32524 KB Output is correct
26 Correct 95 ms 32524 KB Output is correct
27 Correct 88 ms 32524 KB Output is correct
28 Correct 6 ms 32524 KB Output is correct
29 Correct 16 ms 32524 KB Output is correct
30 Correct 8 ms 32524 KB Output is correct
31 Correct 10 ms 32524 KB Output is correct
32 Correct 8 ms 32524 KB Output is correct
33 Correct 30 ms 32524 KB Output is correct
34 Correct 23 ms 32524 KB Output is correct
35 Correct 30 ms 32524 KB Output is correct
36 Correct 8 ms 32524 KB Output is correct
37 Correct 35 ms 32524 KB Output is correct
38 Correct 52 ms 32524 KB Output is correct
39 Correct 38 ms 32524 KB Output is correct
40 Correct 37 ms 32524 KB Output is correct
41 Correct 42 ms 32524 KB Output is correct
42 Execution timed out 1018 ms 263168 KB Time limit exceeded
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 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 -