Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:Notice~老做水题~作孽啊~贡献脑残代码~#include<iostream> #include<fstream> using namespace std; int value[10020]; int main() { //ifstream cin("a.txt"); int tot, n, a, b, c, d; cin>>tot; while (tot--) { memset(value, 0, sizeof(value)); cin>>n; for (int i = 1; i <= n - 1; i++) { cin>>a>>b; value[b] = a; } cin>>c>>d; while (c) { int t = 1, k = d; while (k) { if (c == k) { printf("%d\n", c); t = 0;break; } k = value[k]; } if (!t)break; c = value[c]; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator