| ||||||||||
| 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:哪位兄弟帮我看一下啊!怎么总是 WA啊In Reply To:哪位兄弟帮我看一下啊!怎么总是 WA啊 Posted by:yangjie at 2006-03-13 22:16:09 问题所在
1 2 2 3 3 1 0 0
Case 1 is a tree.
-1 -1
> #include <iostream>
> using namespace std;
>
> int main()
> {
> int check[1000][2];
> int countX(0),countY(0);
> int pointX,pointY,number(0);
>
> cin >> pointX >> pointY;
> while( pointX != -1 || pointY != -1)
> {
> int judge(0);
> while( pointX != 0 || pointY != 0)
> {
>
> check[countX++][0] = pointX;
> check[countY++][1] = pointY;
> cin >> pointX >> pointY;
>
> }
>
> for(int i = 0 ; i < countX ; ++i)
> {
> for(int j = 0 ; j < countX ; ++j)
> {
> if( (check[i][1] == check[j][1] && check[i][0] != check[j][0])|| (check[i][1] == check[j][0]&&check[i][0] == check[j][1]) ||(check[i][0] == check[i][1]) )
> {
> judge = 1;
> break;
> }
> if(i != j && check[i][0] == check[j][0] && check[i][1]==check[j][1])
> {
> judge = 1;
> break;
> }
> }
>
> if(judge)break;
> }
> if(judge)
> cout << "Case "<< ++number <<" is not a tree."<<endl;
> else
> cout << "Case " << ++number << " is a tree."<<endl;
> cin >> pointX >> pointY;
> countX = 0;
> countY = 0;
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator