File size: 5,583 Bytes
e0b2a67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
code`block`FunctionDecl`FunctionDeclRec`ForStmt`ForStmtRec`DoStmt`DoStmtRec`WhileStmt`WhileStmtRec`IfStmt`IfStmtRec`SwitchStmt`SwitchStmtRec`countBlocks`countBlocksRec`countCondition`countVariable`countLiteral`IntegerLiteral`StringLiteral`IfStmt`ForStmt`WhileStmt`DoStmt`SwitchStmt`countLoop`VarDecl`DeclRefExpr`DeclStmt`countDecl`countPointer`writeFunction`CallExpr`BinaryOperator`UnaryOperator`CompoundAssignOperator`countOperand`ArraySubscriptE`RealFaultLocation
int find_set(int p)`FunctionDecl,true;`1`1`0`0`0`0`0`0`0`0`0`0`1`1`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0
	if(uset[p] < 0) return p;`FunctionDecl,true;IfStmt,false;`1`1`0`0`0`0`0`0`1`0`0`0`2`1`1`3`1`1`0`1`0`0`0`0`0`0`3`0`3`0`0`0`1`0`0`1`1`0
	return uset[p] = find_set(uset[p]);`FunctionDecl,true;`1`1`0`0`0`0`0`0`0`0`0`0`1`1`0`4`0`0`0`0`0`0`0`0`0`0`5`0`5`0`1`1`1`0`0`1`2`0
void join(int p, int q)`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0
	p = find_set(p);`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`2`0`0`0`0`0`0`0`0`0`0`3`0`3`0`1`1`1`0`0`1`0`0
	q = find_set(q);`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`2`0`0`0`0`0`0`0`0`0`0`3`0`3`0`1`1`1`0`0`1`0`0
	if(p == q) return;`FunctionDecl,false;IfStmt,false;`1`0`0`0`0`0`0`0`1`0`0`0`2`0`1`2`0`0`0`1`0`0`0`0`0`0`2`0`2`0`0`0`1`0`0`1`0`0
	uset[p] = q;`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`3`0`0`0`0`0`0`0`0`0`0`3`0`3`0`0`0`1`0`0`1`1`0
int main()`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0
	while(~scanf("%d%d", &n, &m))`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`2`1`0`1`0`0`1`0`0`1`0`3`0`3`2`0`1`0`3`0`3`0`0
		int ans = 0;`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`0`1`1`0`0`0`0`0`0`0`1`0`1`2`0`0`0`0`0`0`0`0`0
		memset(uset, -1, sizeof(uset));`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`2`1`1`0`0`0`0`0`0`0`0`3`0`3`0`0`1`0`1`0`1`0`0
		memset(mp, 0, sizeof(mp));`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`2`1`1`0`0`0`0`0`0`0`0`3`0`3`0`0`1`0`0`0`0`0`0
		memset(use, 0, sizeof(use));`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`2`1`1`0`0`0`0`0`0`0`0`3`0`3`0`0`1`0`0`0`0`0`0
		for(int i=1; i<=n; ++i)`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`3`1`1`0`0`1`0`0`0`1`1`3`1`5`0`0`0`1`1`0`2`0`0
			scanf("%d", &mp[i][0]);`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`2`2`1`1`0`0`0`0`0`0`0`3`0`3`1`0`1`0`1`0`1`2`0
			if(0 == mp[i][0])`FunctionDecl,false;WhileStmt,false;ForStmt,false;IfStmt,false;`1`0`1`0`0`0`1`0`1`0`0`0`4`0`3`2`2`2`0`1`0`0`0`0`0`0`2`0`2`0`0`0`1`0`0`1`2`0
				++ans;`FunctionDecl,false;WhileStmt,false;ForStmt,false;IfStmt,false;`1`0`1`0`0`0`1`0`1`0`0`0`4`0`3`1`0`0`0`0`0`0`0`0`0`0`1`0`1`0`0`0`0`1`0`1`0`0
			for(int j=1; j<=mp[i][0]; ++j)`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;`1`0`2`0`0`0`1`0`0`0`0`0`4`0`3`4`2`2`0`0`1`0`0`0`1`1`4`1`6`0`0`0`1`1`0`2`2`0
				int x;`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;`1`0`2`0`0`0`1`0`0`0`0`0`4`0`3`0`0`0`0`0`0`0`0`0`0`1`0`1`2`0`0`0`0`0`0`0`0`0
				scanf("%d", &x);`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;`1`0`2`0`0`0`1`0`0`0`0`0`4`0`3`1`1`0`1`0`0`0`0`0`0`0`2`0`2`1`0`1`0`1`0`1`0`0
				mp[i][x] = 1;`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;`1`0`2`0`0`0`1`0`0`0`0`0`4`0`3`3`1`1`0`0`0`0`0`0`0`0`3`0`3`0`0`0`1`0`0`1`2`0
		for(int i=1; i<n; ++i)`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`3`1`1`0`0`1`0`0`0`1`1`3`1`5`0`0`0`1`1`0`2`0`1
			for(int j=i+1; j<=n; ++j)`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;`1`0`2`0`0`0`1`0`0`0`0`0`4`0`3`4`1`1`0`0`1`0`0`0`1`1`4`1`6`0`0`0`2`1`0`3`0`0
				for(int k=1; k<=m; ++k)`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;ForStmt,false;`1`0`3`0`0`0`1`0`0`0`0`0`5`0`4`3`1`1`0`0`1`0`0`0`1`1`3`1`5`0`0`0`1`1`0`2`0`0
					if(1==mp[i][k] && 1==mp[j][k])`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;ForStmt,false;IfStmt,false;`1`0`3`0`0`0`1`0`1`0`0`0`6`0`7`6`2`2`0`1`0`0`0`0`0`0`6`0`6`0`0`0`3`0`0`3`4`0
						join(i, j);`FunctionDecl,false;WhileStmt,false;ForStmt,false;ForStmt,false;ForStmt,false;IfStmt,false;`1`0`3`0`0`0`1`0`1`0`0`0`6`0`7`2`0`0`0`0`0`0`0`0`0`0`3`0`3`0`1`1`0`0`0`0`0`0
		for(int i=1; i<=n; ++i)`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`3`1`1`0`0`1`0`0`0`1`1`3`1`5`0`0`0`1`1`0`2`0`0
			if(0 == mp[i][0]) continue;`FunctionDecl,false;WhileStmt,false;ForStmt,false;IfStmt,false;`1`0`1`0`0`0`1`0`1`0`0`0`4`0`3`2`2`2`0`1`0`0`0`0`0`0`2`0`2`0`0`0`1`0`0`1`2`0
			int p = find_set(i);`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`1`0`0`0`0`0`0`0`0`0`1`2`1`4`0`1`1`0`0`0`0`0`0
			if(use[p]) continue;`FunctionDecl,false;WhileStmt,false;ForStmt,false;IfStmt,false;`1`0`1`0`0`0`1`0`1`0`0`0`4`0`3`2`0`0`0`1`0`0`0`0`0`0`2`0`2`0`0`0`0`0`0`0`1`0
			++ans;`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`1`0`0`0`0`0`0`0`0`0`0`1`0`1`0`0`0`0`1`0`1`0`0
			use[p] = 1;`FunctionDecl,false;WhileStmt,false;ForStmt,false;`1`0`1`0`0`0`1`0`0`0`0`0`3`0`2`2`1`1`0`0`0`0`0`0`0`0`2`0`2`0`0`0`1`0`0`1`1`0
		printf("%d\n", ans-1);`FunctionDecl,false;WhileStmt,false;`1`0`0`0`0`0`1`0`0`0`0`0`2`0`1`1`2`1`1`0`0`0`0`0`0`0`2`0`2`0`0`1`1`0`0`1`0`0
	return 0;`FunctionDecl,false;`1`0`0`0`0`0`0`0`0`0`0`0`1`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0