# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1064874 |
2024-08-18T18:49:04 Z |
Osplei |
Stations (IOI20_stations) |
C++17 |
|
636 ms |
25264 KB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector <int> bfs (int n, int nodo, vector <int> grafo[1000005]){
vector <int> aux(n);
bool visto[1000005];
queue <pair <int, int>> q;
for (int i = 0; i < 1000005; i++) visto[i] = false;
q.push({nodo, 0});
aux[nodo] = 0;
while (!q.empty()){
pair <int, int> act = q.front();
q.pop();
if (visto[act.first] == true) continue;
visto[act.first] = true;
if (grafo[act.first].size() <= 2){
for (auto i : grafo[act.first]) {
if (visto[i] != true){
q.push({i, act.second});
aux[i] = act.first + 1 + act.second;
}
}
} else {
int auxi = 2000;
aux[act.first] = 1e9;
for (auto i : grafo[act.first]) {
q.push({i, auxi});
aux[i] = act.first + 1 + auxi;
auxi += 2000;
}
}
}
return aux;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
vector <int> grafo[1000005];
for (int i = 0; i < u.size(); i++) {
int a = u[i], b = v[i];
grafo[a].pb(b);
grafo[b].pb(a);
}
for (int i = 0; i < n; i++){
if (grafo[i].size() == 1){
vector <int> labels = bfs(n, i, grafo);
//for (auto j : labels) cout << j << " ";
return labels;
}
}
return u;
}
int find_next_station(int s, int t, vector <int> c) {
int maxi = 1e9;
if (c.size() == 1) return c[0];
if (s != maxi){
if (t >= s + 2000 || t <= s + 2000) return min(c[0], c[1]);
else {
if (t > s) return max(c[0], c[1]);
else return min(c[0], c[1]);
}
} else {
return -1;
for (auto i : c) {
if (i + 2000 >= t && i <= t) return i;
}
}
}
/*
int main(){
label(5, 10, {0, 3, 4, 2}, {1, 4, 0, 1});
}
*/
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:52:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i < u.size(); i++) {
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
358 ms |
25208 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
24920 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=2002 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
401 ms |
25260 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
636 ms |
25004 KB |
Output is correct |
2 |
Incorrect |
471 ms |
25200 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
395 ms |
25264 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |