Submission #310315

# Submission time Handle Problem Language Result Execution time Memory
310315 2020-10-06T16:08:50 Z Peacher29 Stations (IOI20_stations) C++14
0 / 100
862 ms 1024 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

class pont{
public:
	vector<int> v;
	int id=-1;
	void dfs(bool mi);
};

int dd;
vector<pont> p;

void pont::dfs(bool mi){
	if(id==-1){
		if(mi){
			id=-2;
		} else {
			id=++dd;
		}
		for(int i : v){
			p[i].dfs(!mi);
		}
		if(mi){
			id=++dd;
		}
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	p.clear();
	p.resize(n);
	dd=-1;
	for(int i=0;i<n-1;i++){
		p[u[i]].v.push_back(v[i]);
		p[v[i]].v.push_back(u[i]);
	}
	p[0].dfs(0);
	vector<int> er(n);
	for(int i=0;i<n;i++){
		er[i] = p[i].id;
	}
	return er;
}
int find_next_station(int s, int t, vector<int> c) {
	if(s==t){
		exit(255);
	}
	if(c.size()==1){
		return c[0];
	}
	sort(c.begin(), c.end());
	/*for(int i : c){
		cout << i << ' ';
	}*/
	//cout << '\n';
	if(s<c[0]){
		if(t<s || c[c.size()-2]<t){
			return c[c.size()-1];
		} else {
			for(int i=1;i<c.size()-2+(s==0);i++){
				if(t<=c[i]){
					return c[i];
				}
			}
		}
	} else {
		if(t>s || c[1]>t){
			return c[0];
		} else {
			for(int i=c.size()-1;i>0;i--){
				if(c[i]<=t){
					return c[i];
				}
			}
		}
	}
	exit(255);
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |    for(int i=1;i<c.size()-2+(s==0);i++){
      |                ~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1012 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1008 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1024 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 862 ms 648 KB Output is correct
2 Runtime error 2 ms 648 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 772 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -