# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306841 | 2020-09-26T10:46:25 Z | Ruxandra985 | Stations (IOI20_stations) | C++14 | 1158 ms | 1164 KB |
#include <bits/stdc++.h> #include "stations.h" #define DIMN 1010 using namespace std; int poz; int lab[DIMN] , last[DIMN] , niv[DIMN]; vector <int> ww[DIMN]; void dfs (int nod , int tt , int lvl){ int i , vecin; if (lvl % 2 == 0) poz++; lab[nod] = poz; niv[nod] = lvl; for (i = 0 ; i < ww[nod].size() ; i++){ vecin = ww[nod][i]; if (vecin != tt){ dfs (vecin , nod , lvl + 1); } } if (lvl % 2 == 1) poz++; last[nod] = poz; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels; for (int i = 0 ; i < n ; i++) ww[i].clear(); for (int i = 0; i < u.size(); i++) { ww[u[i]].push_back(v[i]); ww[v[i]].push_back(u[i]); } poz = 0; dfs (0 , -1 , 0); for (int i = 0 ; i < n ; i++){ if (niv[i] % 2 == 0) labels.push_back(lab[i]); else labels.push_back(last[i]); } return labels; } int find_next_station(int s, int t, vector<int> c) { int i; if (c.size() == 1) return c[0]; if (s == 1){ /// incep din 0, e nivel par oricum for (i = 0 ; i <= c.size() - 1 ; i++){ if (c[i] < t && t <= c[i + 1]) return c[i + 1]; } return c[0]; } else { /// unul dintre vecini e clar tatal if (s < c[0]){ /// s e un nivel par if (s <= t && t <= c[0]) return c[0]; for (i = 0 ; i <= c.size() - 2 ; i++){ if (c[i] < t && t <= c[i + 1]) return c[i + 1]; } return c.back(); } else { /// s e un nivel impar for (i = 1 ; i <= c.size() - 1 ; i++){ if (c[i] <= t && t < c[i + 1]) return c[i]; } if (t >= c.back() && t < s) return c.back(); return c[0]; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 580 ms | 1024 KB | Output is correct |
2 | Correct | 472 ms | 1008 KB | Output is correct |
3 | Correct | 864 ms | 868 KB | Output is correct |
4 | Correct | 638 ms | 992 KB | Output is correct |
5 | Correct | 600 ms | 868 KB | Output is correct |
6 | Correct | 472 ms | 1008 KB | Output is correct |
7 | Correct | 426 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 876 KB | Output is correct |
9 | Correct | 4 ms | 868 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 494 ms | 1048 KB | Output is correct |
2 | Incorrect | 531 ms | 932 KB | Wrong query response. |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 550 ms | 1024 KB | Output is correct |
2 | Correct | 517 ms | 1024 KB | Output is correct |
3 | Correct | 939 ms | 768 KB | Output is correct |
4 | Correct | 655 ms | 864 KB | Output is correct |
5 | Correct | 672 ms | 868 KB | Output is correct |
6 | Correct | 502 ms | 1024 KB | Output is correct |
7 | Correct | 521 ms | 1008 KB | Output is correct |
8 | Correct | 3 ms | 868 KB | Output is correct |
9 | Correct | 4 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 768 KB | Output is correct |
11 | Correct | 674 ms | 768 KB | Output is correct |
12 | Incorrect | 506 ms | 1024 KB | Wrong query response. |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1065 ms | 768 KB | Output is correct |
2 | Correct | 677 ms | 768 KB | Output is correct |
3 | Correct | 627 ms | 792 KB | Output is correct |
4 | Correct | 3 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 2 ms | 872 KB | Output is correct |
7 | Correct | 688 ms | 768 KB | Output is correct |
8 | Correct | 1158 ms | 1024 KB | Output is correct |
9 | Correct | 795 ms | 996 KB | Output is correct |
10 | Correct | 793 ms | 864 KB | Output is correct |
11 | Incorrect | 4 ms | 864 KB | Wrong query response. |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 648 ms | 1016 KB | Output is correct |
2 | Correct | 496 ms | 1024 KB | Output is correct |
3 | Correct | 969 ms | 768 KB | Output is correct |
4 | Correct | 739 ms | 1164 KB | Output is correct |
5 | Correct | 699 ms | 768 KB | Output is correct |
6 | Correct | 490 ms | 1024 KB | Output is correct |
7 | Correct | 490 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 864 KB | Output is correct |
9 | Correct | 3 ms | 768 KB | Output is correct |
10 | Correct | 1 ms | 868 KB | Output is correct |
11 | Correct | 515 ms | 808 KB | Output is correct |
12 | Incorrect | 612 ms | 808 KB | Wrong query response. |
13 | Halted | 0 ms | 0 KB | - |