#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include "stations.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;
using namespace std;
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
ll counter = 0;
vector<vector<ll>> g(n);
rep(i, 0, n - 1) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
ll cur = 0;
queue<ll> q;
rep(i, 0, g.size()) {
if (g[i].size() == 1)q.push(i);
}
vector<int> ans(n);
vector<bool> visited(n);
ll counter2 = 0;
while (!q.empty()) {
cur = q.front();
q.pop();
while (counter < n) {
visited[cur] = 1;
ans[cur] = counter2++;
counter++;
trav(a, g[cur])if (!visited[a])cur = a;
if (g[cur].size() > 2) {
counter2 = ((counter2 / 2000) + 1) * 2000;
ans[cur] = 1e5;
break;
}
}
}
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
int ans;
if (abs(s - t) > 1000) {
ans = -1;
trav(a, c)ans = max(a, ans);
}
else if (s < t) {
ans = -1;
trav(a, c)ans = max(a, ans);
}
else {
ans = 1e7;
trav(a, c)ans = min(a, ans);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
667 ms |
556 KB |
Output is correct |
2 |
Correct |
449 ms |
552 KB |
Output is correct |
3 |
Correct |
1267 ms |
400 KB |
Output is correct |
4 |
Correct |
957 ms |
476 KB |
Output is correct |
5 |
Correct |
780 ms |
468 KB |
Output is correct |
6 |
Correct |
637 ms |
544 KB |
Output is correct |
7 |
Correct |
498 ms |
484 KB |
Output is correct |
8 |
Correct |
2 ms |
472 KB |
Output is correct |
9 |
Correct |
7 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
320 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
769 ms |
484 KB |
Output is correct |
2 |
Correct |
608 ms |
488 KB |
Output is correct |
3 |
Correct |
1351 ms |
400 KB |
Output is correct |
4 |
Correct |
693 ms |
400 KB |
Output is correct |
5 |
Correct |
769 ms |
560 KB |
Output is correct |
6 |
Correct |
668 ms |
540 KB |
Output is correct |
7 |
Correct |
613 ms |
572 KB |
Output is correct |
8 |
Correct |
3 ms |
476 KB |
Output is correct |
9 |
Correct |
3 ms |
584 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Incorrect |
778 ms |
488 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1224 ms |
464 KB |
Output is correct |
2 |
Correct |
940 ms |
532 KB |
Output is correct |
3 |
Correct |
935 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Incorrect |
797 ms |
488 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
509 ms |
488 KB |
Output is correct |
2 |
Correct |
575 ms |
488 KB |
Output is correct |
3 |
Correct |
1063 ms |
596 KB |
Output is correct |
4 |
Correct |
763 ms |
488 KB |
Output is correct |
5 |
Correct |
839 ms |
400 KB |
Output is correct |
6 |
Correct |
546 ms |
484 KB |
Output is correct |
7 |
Correct |
462 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
11 |
Incorrect |
6 ms |
280 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |