Submission #921258

# Submission time Handle Problem Language Result Execution time Memory
921258 2024-02-03T15:44:18 Z Nika533 Rail (IOI14_rail) C++14
8 / 100
216 ms 98628 KB
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "rail.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
const int N=5e3+5;
int n,m,T,k;
int dist[N][N];
pii c[N];

void findLocation(int N, int first, int location[], int stype[])
{
	int n=N;
	stype[0]=1; location[0]=first;
	for (int i=0; i<n; i++) {
		dist[i][i]=0; c[i]={1e9,-1};
		for (int j=i+1; j<n; j++) {
			dist[i][j]=getDistance(i,j);
			dist[j][i]=dist[i][j];
		}
	}
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (i==j) continue;
			if (dist[i][j]<c[i].f) {
				c[i]={dist[i][j],j};
			}
		}
	}
	
	int y=c[0].s; stype[y]=2; location[y]=location[0]+c[0].f;
	int x=c[y].s; stype[x]=1; location[x]=location[y]-c[y].f;
	
	//cout<<"XY "<<x<<" "<<y<<endl;
	
	vector<int> v;
	for (int i=0; i<n; i++) {
		if (i==x || i==y) continue;
		if (dist[y][i]<dist[x][i]) v.pb(i);
	}
	
	pii l={dist[x][y],x};
	for (auto a:v) {
		int b=c[a].s;
		if (b==y || dist[a][y]<dist[b][y]) {
			stype[a]=1;
			if (dist[y][a]>l.f) {
				l={dist[y][a],a};
			}
		}
	}
	
	location[l.s]=location[y]-l.f;
	int L=l.s;
	
	for (int i=0; i<n; i++) {
		if (i==L) continue;
		int j=c[i].s;
		if (j==L || dist[L][i]<dist[L][j]) {
			stype[i]=2;
			location[i]=location[L]+dist[L][i];
		}
		else {
			stype[i]=1;
			location[i]=location[L]+dist[L][j]-dist[i][j];
		}
	}
//	cout<<"L "<<L<<endl;
//	for (int i=0; i<n; i++) {
//		cout<<stype[i]<<" "<<location[i]<<endl;
//	}
}

Compilation message

rail.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 214 ms 98604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 98628 KB Output isn't correct
2 Halted 0 ms 0 KB -