-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1308.cpp
More file actions
39 lines (37 loc) · 1.15 KB
/
1308.cpp
File metadata and controls
39 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
#define fromto(from,to,i) for(int i=(from);i<=(to);++i)
#define fromdownto(from,to,i) for(int i=(from);i>=(to);--i)
#define fromgoto(from,to,i) for(int i=(from),__size=(to);i<=__size;++i)
#define foreach(v,p,type) for(type::iterator p=(v).begin();p!=(v).end();++p)
#define MP make_pair
#define INF INT_MAX
#define MAXN 200
int fa[MAXN];
int getroot(int v){return fa[v]==v?v:(fa[v]=getroot(fa[v]));}
void sinit(){for(int i=0;i<MAXN;++i) fa[i]=i;}
int main() {
for(int case_num=1;;++case_num) {
unsigned int cnt=0;
set<int> S,S_t;
bool OK=true;
while(true) {
int a,b; scanf("%d%d",&a,&b);
if(a==-1 && b==-1) return 0;
if(a==0 && b==0) break;
++cnt;
S.insert(a);S.insert(b);
if(S_t.find(b)==S_t.end()) S_t.insert(b);
else OK=false;
}
if((S.size()==cnt+1 && OK) || cnt==0) printf("Case %d is a tree.\n",case_num);
else printf("Case %d is not a tree.\n",case_num);
}
return 0;
}