Submission #541586

# Submission time Handle Problem Language Result Execution time Memory
541586 2022-03-23T19:31:54 Z Vladth11 Stations (IOI20_stations) C++14
0 / 100
785 ms 640 KB
#include <bits/stdc++.h>
#include "stations.h"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;

const ll NMAX = 1001;
const ll VMAX = 1000001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 1000000;
const ll nr_of_bits = 16;

vector <int> sol;
vector <int> g[NMAX];
int stamp;

void DFS(int node, int p){
    for(auto x : g[node]){
        if(x == p)
            continue;
        DFS(x, node);
    }
    sol[node] = stamp++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	sol.clear();
	sol.resize(n);
	stamp = 0;
	for(int i = 0; i < n; i++)
        g[i].clear();
	for (int i = 0; i < n - 1; i++) {
        int a = u[i];
        int b = v[i];
        g[a].push_back(b);
        g[b].push_back(a);
	}
    DFS(0, -1);
    return sol;
}

int find_next_station(int s, int t, vector<int> c) {
    sort(c.begin(), c.end());
    for(int i = 0; i < c.size() - 1; i++){
        if(t <= c[i]){
            return c[i];
        }
    }
    return c.back();
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i = 0; i < c.size() - 1; i++){
      |                    ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 450 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 430 ms 548 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 489 ms 640 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 785 ms 508 KB Output is correct
2 Correct 665 ms 416 KB Output is correct
3 Incorrect 604 ms 596 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 533 ms 544 KB Wrong query response.
2 Halted 0 ms 0 KB -