Submission #831387

#TimeUsernameProblemLanguageResultExecution timeMemory
831387TrumlingStations (IOI20_stations)C++14
8 / 100
772 ms512 KiB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define pb push_back
#define INF 9999999999999999
vector<vector<int>>g;
ll nn;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
/*
	g.assign(n,vector<int>());

	for (int i = 0; i < n-1; i++) {
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	
*/
nn =n;

vector<int>labels(n);
for(int  i=0;i<n;i++)
labels[i]=i;

return labels;
}

int find_next_station(int s, int t, vector<int> c) 
{
	int mini=INF;

	for(auto x:c)
	mini=min(x,mini);

	if(t<s)
	return mini;

	queue<pair<int,int>>q;
	q.push({s*2+2,1});
	q.push({s*2+1,0});

	int tf=-1;

	while(!q.empty())
	{
		pair<int,int> curr=q.front();
		if(curr.F==t)
		{
			tf=curr.S;
			break;
			
		}
		q.pop();
		if(curr.F*2+1 ==t)
		{
			tf=curr.S;
			break;
		}

		if(curr.F*2+2 ==t)
		{
			tf=curr.S;
			break;
		}
		if(curr.F*2+1<t)
		q.push({curr.F*2+1,curr.S});

		if(curr.F*2+2<t)
		q.push({curr.F*2+2,curr.S});
	}
	if(tf==-1)
	return mini;
	if(tf==0)
	return s*2+1;
	else
	return s*2+2;

}

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:11:13: warning: overflow in conversion from 'long int' to 'int' changes value from '9999999999999999' to '1874919423' [-Woverflow]
   11 | #define INF 9999999999999999
      |             ^~~~~~~~~~~~~~~~
stations.cpp:35:11: note: in expansion of macro 'INF'
   35 |  int mini=INF;
      |           ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...