結果

問題 No.2684 折々の色
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-03-21 01:10:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,041 ms / 2,000 ms
コード長 2,467 bytes
コンパイル時間 3,460 ms
コンパイル使用メモリ 215,256 KB
実行使用メモリ 43,156 KB
最終ジャッジ日時 2024-03-21 01:10:44
合計ジャッジ時間 26,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 233 ms
25,600 KB
testcase_12 AC 133 ms
16,896 KB
testcase_13 AC 506 ms
33,440 KB
testcase_14 AC 225 ms
17,408 KB
testcase_15 AC 143 ms
21,120 KB
testcase_16 AC 24 ms
7,808 KB
testcase_17 AC 96 ms
14,848 KB
testcase_18 AC 446 ms
37,448 KB
testcase_19 AC 487 ms
32,256 KB
testcase_20 AC 310 ms
19,456 KB
testcase_21 AC 94 ms
12,672 KB
testcase_22 AC 547 ms
38,508 KB
testcase_23 AC 349 ms
21,888 KB
testcase_24 AC 155 ms
15,872 KB
testcase_25 AC 244 ms
18,560 KB
testcase_26 AC 512 ms
27,776 KB
testcase_27 AC 284 ms
19,840 KB
testcase_28 AC 340 ms
21,632 KB
testcase_29 AC 403 ms
32,464 KB
testcase_30 AC 320 ms
31,200 KB
testcase_31 AC 861 ms
43,132 KB
testcase_32 AC 518 ms
40,612 KB
testcase_33 AC 279 ms
26,408 KB
testcase_34 AC 426 ms
35,912 KB
testcase_35 AC 388 ms
35,380 KB
testcase_36 AC 849 ms
42,720 KB
testcase_37 AC 752 ms
43,120 KB
testcase_38 AC 1,009 ms
43,156 KB
testcase_39 AC 1,003 ms
43,156 KB
testcase_40 AC 1,021 ms
43,156 KB
testcase_41 AC 999 ms
43,156 KB
testcase_42 AC 974 ms
43,156 KB
testcase_43 AC 1,006 ms
43,156 KB
testcase_44 AC 999 ms
43,156 KB
testcase_45 AC 996 ms
43,156 KB
testcase_46 AC 1,041 ms
43,156 KB
testcase_47 AC 2 ms
6,548 KB
testcase_48 AC 2 ms
6,548 KB
testcase_49 AC 2 ms
6,548 KB
testcase_50 AC 2 ms
6,548 KB
testcase_51 AC 2 ms
6,548 KB
testcase_52 AC 1 ms
6,548 KB
testcase_53 AC 2 ms
6,548 KB
testcase_54 AC 2 ms
6,548 KB
testcase_55 AC 1 ms
6,548 KB
testcase_56 AC 1 ms
6,548 KB
testcase_57 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    vector<vector<int>> c(n, vector<int>(m));
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c[i][j];
        }
        cin >> t[i];
    }
    for (int i = 0; i < n; i++) {
        if (t[i] == 100 && c[i] == x) {
            cout << "Yes\n";
            return 0;
        }
    }
    set<array<pair<int, int>, 10>> st;
    for (int i = 0; i < n; i++) {
        if (t[i] != 100) {
            array<pair<int, int>, 10> need;
            for (int j = 0; j < m; j++) {
                int a = 100 * x[j] - t[i] * c[i][j];
                int b = 100 - t[i];
                int g = gcd(a, b);
                if (a < 0) {
                    a = -a;
                    b = -b;
                }
                need[j] = {a / g, b / g};
            }
            if (st.count(need)) {
                cout << "Yes\n";
                return 0;
            }
        }

        array<pair<int, int>, 10> data;
        for (int j = 0; j < m; j++) {
            int a = t[i] * c[i][j];
            int b = 100;
            int g = gcd(a, b);
            if (a < 0) {
                a = -a;
                b = -b;
            }
            data[j] = {a / g, b / g};
        }
        st.insert(data);
    }
    st.clear();
    for (int i = n - 1; i >= 0; i--) {
        if (t[i] != 100) {
            array<pair<int, int>, 10> need;
            for (int j = 0; j < m; j++) {
                int a = 100 * x[j] - t[i] * c[i][j];
                int b = 100 - t[i];
                int g = gcd(a, b);
                if (a < 0) {
                    a = -a;
                    b = -b;
                }
                need[j] = {a / g, b / g};
            }
            if (st.count(need)) {
                cout << "Yes\n";
                return 0;
            }
        }

        array<pair<int, int>, 10> data;
        for (int j = 0; j < m; j++) {
            int a = t[i] * c[i][j];
            int b = 100;
            int g = gcd(a, b);
            if (a < 0) {
                a = -a;
                b = -b;
            }
            data[j] = {a / g, b / g};
        }
        st.insert(data);
    }
    cout << "No\n";
}
0