結果

問題 No.1773 Love Triangle
ユーザー 👑 hitonanodehitonanode
提出日時 2021-11-13 12:47:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,514 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 113,444 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 22:09:20
合計ジャッジ時間 10,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 89 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 AC 13 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 123 ms
4,380 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 128 ms
4,380 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 125 ms
4,376 KB
testcase_52 AC 124 ms
4,376 KB
testcase_53 AC 125 ms
4,376 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 123 ms
4,380 KB
testcase_57 AC 124 ms
4,376 KB
testcase_58 WA -
testcase_59 AC 130 ms
4,376 KB
testcase_60 WA -
testcase_61 AC 128 ms
4,380 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 AC 130 ms
4,376 KB
testcase_65 AC 130 ms
4,376 KB
testcase_66 AC 129 ms
4,376 KB
testcase_67 WA -
testcase_68 AC 130 ms
4,380 KB
testcase_69 AC 128 ms
4,380 KB
testcase_70 WA -
testcase_71 AC 129 ms
4,376 KB
testcase_72 WA -
testcase_73 AC 130 ms
4,376 KB
testcase_74 AC 130 ms
4,376 KB
testcase_75 WA -
testcase_76 AC 130 ms
4,380 KB
testcase_77 WA -
testcase_78 AC 2 ms
4,376 KB
testcase_79 AC 3 ms
4,380 KB
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// This should be WA
#include <chrono>
#include <iostream>
#include <tuple>
#include <random>
#include <vector>
using namespace std;

#include <atcoder/modint>
using mint = atcoder::modint1000000007;

template <class T> int rank_of_matrix(std::vector<std::vector<T>> &M) {
    const int N = M.size();
    int rank = 0;
    for (int i = 0; i < N; ++i) {
        int ti = i;
        while (ti < N and M[ti][i] == 0) ti++;
        if (ti == N) continue;
        ++rank;
        M[i].swap(M[ti]);
        T inv = T(1) / M[i][i];
        for (int j = i + 1; j < N; ++j) M[i][j] *= inv;
        for (int h = 0; h < N; ++h) {
            if (i == h) continue;
            const T c = -M[h][i];
            for (int j = i + 1; j < N; ++j) M[h][j] += M[i][j] * c;
        }
    }
    return rank;
}

mt19937 mt(1967176539);
uniform_int_distribution<int> rndgen(0, mint::mod());

int solve(int N, const vector<tuple<int, int, int>> &uvws) {
    vector M(N, vector<mint>(N));
    // Not bc - cb but bc + cb
    for (auto [u, v, w] : uvws) {

        int x = rndgen(mt);

        M[u][v] += x;
        M[v][u] += x;

        M[v][w] += x;
        M[w][v] += x;

        M[v][v] -= x;
        M[u][w] -= x;
        M[w][u] -= x;
    }
    return rank_of_matrix(M) / 2;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> uvws;
    while (M--) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--, w--;
        uvws.emplace_back(u, v, w);
    }
    cout << solve(N, uvws) << '\n';
}
0