Submission #73211

# Submission time Handle Problem Language Result Execution time Memory
73211 2018-08-28T04:51:02 Z 노영훈(#2269) Circus (Balkan15_CIRCUS) C++11
0 / 100
2000 ms 200228 KB
#include "circus.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;


int D[MX], X[MX], n, m;

void init(int N, int M, int P[]){
	n=N, m=M;
	for(int i=0; i<n; i++) X[i]=P[i];

	sort(X, X+n);
	X[n]=m; D[n]=inf;

	for(int i=0; i<n; i++) D[i]=m-X[i];

	vector<pii> G[MX];
	for(int i=0; i<=n; i++) for(int j=i+1; j<=n; j++){
		G[i].push_back({X[j]-X[i], j});
		G[j].push_back({X[j]-X[i], i});
	}

	priority_queue<pii> Q;
	Q.push({D[n], n});
	while(!Q.empty()){
		int v,d; tie(d,v)=Q.top(); Q.pop();
		for(pii e:G[v]){
			int x,c; tie(x,c)=e;
			if(c>d || D[x]<=c) continue;
			D[x]=c, Q.push({c,x});
		}
	}

	for(int i=0; i<n; i++) cout<<D[i]<<' ';
	cout<<'\n';
}

int minLength(int pos) {
	int res=m-pos;
	for(int i=0; i<n; i++)
		if(abs(pos-X[i])>=D[i]) res=min(res, abs(pos-X[i]));
	return res;
}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:14:12: warning: unused variable 'max_code' [-Wunused-variable]
  long long max_code;
            ^~~~~~~~
grader.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
grader.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &P[i]);
   ~~~~~^~~~~~~~~~~~~
grader.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
grader.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &d);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 200228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 200228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 200228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 200228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 200228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 200228 KB Time limit exceeded
2 Halted 0 ms 0 KB -