結果

問題 No.556 仁義なきサルたち
ユーザー greentea011greentea011
提出日時 2019-03-28 11:49:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,018 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 33,280 KB
実行使用メモリ 817,792 KB
最終ジャッジ日時 2024-04-20 19:04:54
合計ジャッジ時間 2,012 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int s[10010];

int whoisboss(int a) {
    if(s[a]>100000) return a;
    else {
        s[a]=whoisboss(s[a]);
        return s[a];
    }
}

int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    for (int i=0;i<n;i++) {
        s[i]=100001;
    }
    int a,b;
    int ba,bb;
    for (int i=0;i<m;i++) {
        scanf("%d %d",&a,&b);
        printf("***1: %d vs %d\n",a,b);
        ba=whoisboss(a);
        bb=whoisboss(b);
        if (s[ba]>s[bb]) {
            printf("***2: %d Win\n",a);
            s[ba]+=s[bb]%100000;
            s[bb]=a;
        }
        else if (s[ba]==s[bb]) {
            if (ba<bb) {
            printf("***2: %d Win\n",a);
                s[ba]+=s[bb]%100000;
                s[bb]=a;
            }
            else {
            printf("***2: %d Win\n",b);
                s[bb]+=s[ba]%100000;
                s[ba]=b;
            }
        }
        else {
            printf("***2: %d Win\n",b);
            s[bb]+=s[ba]%100000;
            s[ba]=b;
        }
    }
}
0