Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好奇挂的数据啊。

Posted by baicaitest at 2009-09-12 17:05:48 on Problem 1182
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator