ubuntu10.10 重装XP 修复grub
2011-05-07 14:19
519 查看
/* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------------------// Copyright (c) 2012 panyanyany All rights reserved. URL : http://acm.hdu.edu.cn/showproblem.php?pid=1325 Name : 1325 Is It A Tree? Date : Tuesday, April 10, 2012 Time Stage : one hour Result: 5744703 2012-04-10 16:19:24 Accepted 1325 0MS 612K 1133 B C++ pyy Test Data : Review : hdu 的数据比poj弱,没有以下两种情况: 0 0 1 1 0 0 答案都是 not a tree。 除此之外要注意的是循环的情况: 1 2 1 3 2 1 0 0 // not a tree 和两棵树的情况: 1 2 3 4 0 0 //not a tree //----------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <algorithm> #include <iostream> #include <queue> using namespace std ; #define MAXN (1002) int set[MAXN]; int flag; int tcase; void init() { int i; memset(set, -1, sizeof(set)); flag = 0; } int find(int x) { if (set[x] == -1) set[x] = x; if (set[x] == x) return x; return set[x] = find(set[x]); } int main() { int i, j; int x, y; tcase = 1; init(); while (scanf("%d %d", &x, &y) != EOF) { if (x == -1 && y == -1) break; if (x == 0 && y == 0) { printf ("Case %d", tcase++); if (!flag) { j = 0; for (i = 0; i < MAXN; ++i) if (set[i] == i) ++j; if (j > 1) // not a tree: 1 2 3 4 0 0, a tree: 0 0 flag = 1; } if (!flag) { printf (" is a tree.\n"); } else printf (" is not a tree.\n"); init(); continue; } int px = find(x); int py = find(y); if (py != y && px != py || x == y || (x != y && px == py))// not a tree: 1 2 1 3 2 1 0 0 {// not a tree: 1 1 0 0 flag = 1; } else set[py] = set[px]; } return 0; }
相关文章推荐
- XP重装后grub引导修复( Ubuntu10.10 与XP双系统 )
- [Ubuntu] 『亲身操作_非COPY』双系统上重装XP后修复GRUB找回ubuntu『图文全纪录』
- 双系统上重装XP后修复GRUB找回ubuntu
- (转)UBUNTU双系统上重装XP后修复GRUB方法(较全)
- 【转】重装Windows 7后修复Ubuntu 10.10 Grub
- XP + Ubuntu 10.04 双系统 重装XP后 如何修复GRUB
- 重装Windows 7后修复Ubuntu 10.10 Grub【转】
- 重装XP后修复GRUB引导(XP+UBUNTU 双系统)
- 重装XP后修复Ubuntu 9.10操作系统GRUB
- 重装win系统后修复ubuntu的grub引导程序
- ubuntu14.0.4 和 win7 双系统 在重装 win7 后丢失Grub启动引导 修复
- 重装WINDOWS7后修复UBUNTU10.10的启动
- Windows、Ubuntu双系统重装windows系统后grub引导的修复及默认启动项的修改
- 重装win7后修复grub(LiveCD修复)(win7,ubuntu10.10双系统)
- Ubuntu重装windows系统后的grub引导修复
- Windows、Ubuntu双系统重装windows系统后grub引导的修复及默认启动项的修改
- XP+UBUNTU双系统上重装XP后修复GRUB方法
- 重装win7后修复grub(LiveCD修复)(win7,ubuntu10.10双系统)
- ubuntu与win7双系统,重装win7后的grub引导修复
- ubuntu与win7双系统,重装win7后的grub引导修复