# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
321448 |
2020-11-12T11:15:11 Z |
grt |
Stations (IOI20_stations) |
C++17 |
|
886 ms |
1104 KB |
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;
#define ST first
#define ND second
#define PB push_back
const int nax = 1000 + 10;
vi V[nax];
bool visited[nax];
int cur;
int num[nax], dep[nax];
void dfs(int x) {
visited[x] = 1;
if(dep[x]%2==0) {
num[x] = cur;
cur++;
}
for(int nbh : V[x]) if(!visited[nbh]) {
dep[nbh] = dep[x] + 1;
dfs(nbh);
}
if(dep[x]%2==1) {
num[x] = cur;
cur++;
}
}
vi label(int n, int k, vi u, vi v) {
for(int i = 0; i < n; ++i) {
visited[i] = 0;
V[i].clear();
}
for(int i = 0; i < n - 1; ++i) {
V[v[i]].PB(u[i]);
V[u[i]].PB(v[i]);
}
cur = 0;
dfs(0);
vi ans(n);
for(int i = 0; i < n; ++i) ans[i] = num[i];
return ans;
}
int find_next_station(int s, int y, vi c) {
if((int)c.size() == 0) return c.back();
if(s < c[0]) {
int ans = -1;
if(y < s || y > c[(int)c.size() - 2]) {
return c.back();
}
int x = 0;
while(c[x] < y) x++;
return c[x];
} else {
if(y > s || y < c[1]) {
return c[0];
}
int x = (int)c.size() - 1;
while(y < c[x]) x--;
return c[x];
}
}
//int main() {
//vi res = label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4});
//for(int i = 0; i < 5; ++i) cout << res[i] << " ";
//}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:55:13: warning: unused variable 'ans' [-Wunused-variable]
55 | int ans = -1;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
631 ms |
1104 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
639 ms |
972 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
646 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
886 ms |
864 KB |
Output is correct |
2 |
Correct |
716 ms |
1072 KB |
Output is correct |
3 |
Incorrect |
572 ms |
1072 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
535 ms |
1104 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |