659277 386183
1 2
1 3
1 17
1 34
1 311
1 347
1 539
1 1138
1 1472
1 3361
1 7475
1 10600
1 24431
1 3881
<18857310 bytes omitted>
用户输出
626296
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#82259 | #1298. 寻找终点 | Accepted | 100 | 863 ms | 30284 K | C++ 11 / 853 B | y | 2023-03-12 21:33:26 |
#include <algorithm>
#include <vector>
#include <cstdio>
#define N 1000009
#define pb push_back
#define RI register int
using namespace std;
int n, st, ind[N], sd;
vector<int> nxt[N];
inline int read();
void dfs(int u, int ufa) {
int lim = nxt[u].size();
for (RI i = 0, v; i < lim; ++i)
if ((v = nxt[u][i]) != ufa)
return dfs(v, u), void();
printf("%d\n", u);
}
int main() {
n = read(), st = read();
for (RI i = 1, u, v; i < n; ++i) {
u = read(), v = read();
nxt[u].pb(v);
nxt[v].pb(u);
}
for (RI i = 1; i <= n; ++i) sort(nxt[i].begin(), nxt[i].end());
dfs(st, st);
return 0;
}
inline int read() {
int x = 0;
char c = getchar();
while (c > '9' || c < '0') c = getchar();
while (c >= '0' && c <= '9') {
x *= 10;
x += c - '0';
c = getchar();
}
return x;
}
659277 386183
1 2
1 3
1 17
1 34
1 311
1 347
1 539
1 1138
1 1472
1 3361
1 7475
1 10600
1 24431
1 3881
<18857310 bytes omitted>
用户输出
626296
系统信息
Exited with return code 0
256069 235113
1 2
1 3
1 4
1 6
1 10
1 11
1 13
1 34
1 46
1 82
1 115
1 534
1 789
1 1007
2 9
2 456
2 836
<6972062 bytes omitted>
用户输出
186089
系统信息
Exited with return code 0
577392 319668
1 2
1 3
1 7
1 55
1 1360
1 256588
1 323239
1 460008
2 4
2 16
2 24
2 225
2 10553
2 18482
<16431146 bytes omitted>
用户输出
37589
系统信息
Exited with return code 0
881921 4297
1 2
1 5
1 101
1 992
1 2378
1 23833
1 57369
1 62249
1 164836
1 342354
1 634202
2 3
2 4
2
<25472882 bytes omitted>
用户输出
436278
系统信息
Exited with return code 0
690116 401010
1 2
1 3
1 4
1 10
1 14
1 46
1 87
1 159
1 447
1 511
1 523
1 699
1 2025
1 9648
1 12980
1
<19772222 bytes omitted>
用户输出
656490
系统信息
Exited with return code 0
179327 251
1 2
1 3
1 5
1 17
1 70
1 90
1 112
1 1553
1 1775
1 1928
1 2180
1 6766
1 7623
1 67044
1 1279
<4749045 bytes omitted>
用户输出
103582
系统信息
Exited with return code 0
71567 57797
1 2
1 3
1 4
1 24
1 85
1 96
1 106
1 209
1 548
1 11245
1 37632
1 64950
1 67341
2 5
2 6
2 1
<1766792 bytes omitted>
用户输出
5621
系统信息
Exited with return code 0
479057 240031
1 2
1 4
1 14
1 29
1 170
1 326
1 3811
1 6465
1 7184
1 27831
1 36571
1 63687
1 135286
1
<13521216 bytes omitted>
用户输出
313414
系统信息
Exited with return code 0
100481 81388
1 2
1 3
1 6
1 13
1 15
1 29
1 362
1 462
1 1030
1 1454
1 2979
1 5473
1 7570
1 96038
2 4
2
<2512053 bytes omitted>
用户输出
26359
系统信息
Exited with return code 0
438544 368826
1 2
1 21
1 75
1 413
1 993
1 1922
1 31917
1 48275
1 160089
2 3
2 5
2 6
2 19
2 23
2 115
<12326052 bytes omitted>
用户输出
220367
系统信息
Exited with return code 0