| ||||||||||
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 |
为什么会编译错误呀????!!!!(附代码)#include <iostream> #include <cstring> #include <vector> #define MAX 205 using namespace std; void dfs(int p); vector <int> a[MAX]; int num[MAX]; int dp[MAX][2]; int f[MAX][2]; int main() { string name[MAX]; string boss; char temp1[MAX], temp2[MAX]; int n; int i, j; while (scanf("%d", &n) && n) { memset(dp, 0, sizeof(dp)); memset(num, 0, sizeof(num)); memset(temp1, '\0', sizeof(temp1)); memset(temp2, '\0', sizeof(temp2)); scanf("%s", temp1); name[0] = temp1; for (i=1; i<n; i++) { scanf("%s %s", temp1, temp2); name[i] = temp1; boss = temp2; num[i] = i; for (j=0; j<n; j++) { if (name[j] == boss) { a[j].push_back(num[i]); a[i].push_back(num[j]); break; } } } dfs(a[0][0]); memset(f, 1, sizeof(f)); if (dp[0][0] > dp[0][1]) { if (f[0][0] == 0) { printf("%d No\n", dp[0][0]); } else printf("%d Yes\n", dp[0][0]); } else if (dp[0][0] == dp[0][1]) { printf("%d No\n", dp[0][0]); } else { if (f[0][1] == 0) { printf("%d No\n", dp[0][1]); } else printf("%d Yes\n", dp[0][1]); } for (i=0; i<MAX; i++) { a[i].clear(); } } return 0; } void dfs(int p) { unsigned int i; for (i=0; i<a[p].size(); i++) { if (num[a[p][i]] != -1) { num[a[p][i]] = -1; dfs(a[p][i]); dp[p][1] += dp[a[p][i]][0]; if (f[a[p][i]][0] == 0) { f[p][1] = 0; } dp[p][0] += max(dp[a[p][i]][1], dp[a[p][i]][0]); if (dp[a[p][i]][1] == dp[a[p][i]][0]) { f[p][0] = 0; } } } dp[p][1]++; return; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator