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 |
好奇挂的数据啊。int main () { int i, j, cnt = 0; scanf("%d %d", &n, &k); for ( i = 1; i <= n; i++ ) { fa[i] = i; kind[i] = 0; } for ( i = 0; i < k; i++ ) { scanf("%d %d %d", &d, &x, &y); if ( x > n || y > n ) cnt++; else if ( d == 2 && x == y ) cnt++; else { rx = Find(x); ry = Find(y); // printf("rx %d ry %d\n", rx, ry); if ( rx != ry ) Union(x, y); else { if ( d == 1 && kind[x] != kind[y] ) cnt++; else if (/* d == 2 && */( kind[x] - kind[y] + 3 ) % 3 != 2 ) 这里必须要d == 2,否则wa。难道除了1还有不是2的东西存在吗? cnt++; // printf("cnt %d\n", cnt); } } } printf("%d\n", cnt); scanf("%d",&cnt); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator