Setting up a Git project
2008-07-21 16:01
393 查看
/* 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; }
相关文章推荐
- Setting up flash chat application using project Darkstar
- 在Eclipse中显示.project, .classpath, .gitignore文件和.setting文件夹
- Setting up Git on CentOS 5 server
- Setting Up Git Commit Email Notifications
- Setting Up Google Code And Github With Git
- Setting Up Git Server Using Gitosis
- [Android]:Setting up a Library Project and how to use the library (工程引用和dll引用)
- Your First Concordion.Net Project (Part 2)-Setting Up Visual Studio
- Setting up a git server on MacOS X Lion
- Setting up a git remote origin
- Setting up a new remote git repository
- Setting Up a Selenium-WebDriver Project
- setting up a new remote git repository
- Five suggestions for setting up a Go project
- Windows下Setting Up a Project(建立一个工程)
- Setting up a new Typescript 1.9 and React project
- Setting up a Library Project
- CocosBuilder用户手册中文版:2. Setting up a New Project
- Setting up GlassFish for JMS
- Project configuration is not up-to-date with pom.xml