Submission #308606

# Submission time Handle Problem Language Result Execution time Memory
308606 2020-10-01T15:02:57 Z lordlorinc Stations (IOI20_stations) C++17
0 / 100
905 ms 640 KB
#include "stations.h"
#include <vector>

using namespace std;

vector<vector<int> > sor;
vector<bool> volt;
vector<int> eleres, tavozas;
int time = -1;

void bejaras (int hely){
    time++;
    eleres[hely] = time;
    volt[hely] = true;
    for (int x : sor[hely]){
        if (volt[x] == false){
            bejaras(x);
        }
    }
    time++;
    tavozas[hely] = time;
}


std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	sor.assign(n, vector<int>(0));
	volt.assign(n, false);
	eleres.assign(n, 0);
	tavozas.assign(n, 0);
	for (int i = 0; i < u.size(); i++){
        sor[u[i]].push_back(v[i]);
	}

	bejaras(0);

	vector<int> labels(n);

	for (int i = 0; i < n; i++) labels[i] = eleres[i] * 2000 + tavozas[i];

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {

    pair<int, int> hely, cel;
    hely.first = s / 2000;
    hely.second = s % 2000;
    cel.first = t / 2000;
    cel.second = t % 2000;

    vector<pair<int, int> > szomszedok(c.size());

    for (int i = 0; i < c.size(); i++){
        szomszedok[i].first = c[i] / 2000;
        szomszedok[i].second = c[i] % 2000;
    }

    int szuloindex = -1;
    for (int i = 0; i < c.size(); i++) {
        if (szomszedok[i].first < hely.first) szuloindex = i;
    }

    for (int i = 0; i < c.size(); i++){
        if (i != szuloindex){
            if (szomszedok[i].first < cel.first && szomszedok[i].second > cel.second){
                return c[i];
            }
        }
    }



	return c[szuloindex];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < c.size(); i++){
      |                     ~~^~~~~~~~~~
stations.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < c.size(); i++) {
      |                     ~~^~~~~~~~~~
stations.cpp:63:23: 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 = 0; i < c.size(); i++){
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2006
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 905 ms 640 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -