結果

問題 No.2684 折々の色
ユーザー shinchanshinchan
提出日時 2024-03-20 22:33:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 4,732 bytes
コンパイル時間 2,443 ms
コンパイル使用メモリ 215,288 KB
実行使用メモリ 59,620 KB
最終ジャッジ日時 2024-03-20 22:34:24
合計ジャッジ時間 23,515 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 186 ms
28,288 KB
testcase_12 AC 98 ms
18,048 KB
testcase_13 AC 447 ms
34,352 KB
testcase_14 AC 182 ms
19,072 KB
testcase_15 AC 125 ms
22,272 KB
testcase_16 AC 21 ms
7,552 KB
testcase_17 AC 83 ms
16,000 KB
testcase_18 AC 432 ms
32,712 KB
testcase_19 AC 401 ms
35,328 KB
testcase_20 AC 241 ms
26,240 KB
testcase_21 AC 101 ms
11,264 KB
testcase_22 AC 648 ms
33,260 KB
testcase_23 AC 307 ms
26,624 KB
testcase_24 AC 157 ms
14,080 KB
testcase_25 AC 228 ms
18,816 KB
testcase_26 AC 495 ms
34,048 KB
testcase_27 AC 282 ms
23,040 KB
testcase_28 AC 326 ms
26,368 KB
testcase_29 AC 342 ms
46,408 KB
testcase_30 AC 277 ms
40,092 KB
testcase_31 AC 702 ms
53,500 KB
testcase_32 AC 418 ms
56,404 KB
testcase_33 AC 252 ms
38,832 KB
testcase_34 AC 348 ms
45,304 KB
testcase_35 AC 316 ms
44,820 KB
testcase_36 AC 696 ms
53,020 KB
testcase_37 AC 627 ms
53,484 KB
testcase_38 AC 888 ms
59,620 KB
testcase_39 AC 878 ms
59,620 KB
testcase_40 AC 872 ms
59,620 KB
testcase_41 AC 881 ms
59,620 KB
testcase_42 AC 887 ms
59,620 KB
testcase_43 AC 891 ms
59,620 KB
testcase_44 AC 871 ms
59,620 KB
testcase_45 AC 888 ms
59,620 KB
testcase_46 AC 895 ms
59,620 KB
testcase_47 AC 2 ms
6,676 KB
testcase_48 AC 3 ms
6,676 KB
testcase_49 AC 2 ms
6,676 KB
testcase_50 AC 2 ms
6,676 KB
testcase_51 AC 2 ms
6,676 KB
testcase_52 AC 2 ms
6,676 KB
testcase_53 AC 2 ms
6,676 KB
testcase_54 AC 2 ms
6,676 KB
testcase_55 AC 2 ms
6,676 KB
testcase_56 AC 2 ms
6,676 KB
testcase_57 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto&& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

template<int MOD> struct Modint {
    long long val;
    constexpr Modint(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; }
    constexpr int mod() const { return MOD; }
    constexpr long long value() const { return val; }
    constexpr Modint operator - () const noexcept { return val ? MOD - val : 0; }
    constexpr Modint operator + (const Modint& r) const noexcept { return Modint(*this) += r; }
    constexpr Modint operator - (const Modint& r) const noexcept { return Modint(*this) -= r; }
    constexpr Modint operator * (const Modint& r) const noexcept { return Modint(*this) *= r; }
    constexpr Modint operator / (const Modint& r) const noexcept { return Modint(*this) /= r; }
    constexpr Modint& operator += (const Modint& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Modint& operator -= (const Modint& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Modint& operator *= (const Modint& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Modint& operator /= (const Modint& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Modint& r) const noexcept { return this->val == r.val; }
    constexpr bool operator != (const Modint& r) const noexcept { return this->val != r.val; }
    friend constexpr istream& operator >> (istream& is, Modint<MOD>& x) noexcept {
        is >> x.val;
        x.val %= MOD;
        if (x.val < 0) x.val += MOD;
        return is;
    }
    friend constexpr ostream& operator << (ostream& os, const Modint<MOD>& x) noexcept {
        return os << x.val;
    }
    constexpr Modint<MOD> pow(long long n) noexcept {
        if (n == 0) return 1;
        if (n < 0) return this->pow(-n).inv();
        Modint<MOD> ret = pow(n >> 1);
        ret *= ret;
        if (n & 1) ret *= *this;
        return ret;
    }
    constexpr Modint<MOD> inv() noexcept {
        long long a = this->val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        return Modint<MOD>(u);
    }
};

// const int MOD1 = MOD7, MOD2 = MOD998, MOD3 = 1000000007;
// using mint1 = Modint<MOD1>, mint2 = Modint<MOD2>, mint = Modint<MOD3>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i, m) {
        cin >> x[i];
        x[i] *= 10000;
    }
    vector c(n, vector<ll> (m, 0LL));
    vector t(n, 0LL);
    rep(i, n) {
        rep(j, m) cin >> c[i][j];
        cin >> t[i];
    }

    auto solve = [&](bool flag = 0) -> void {
        set<vector<ll>> st;
        rep(i, n) {
            if(t[i] == 100) {
                vector<ll> v(m);
                rep(j, m) {
                    v[j] = c[i][j] * 100 * t[i];
                }
                if(v == x) {
                    cout << "Yes" << endl;
                    exit(0);
                }
            } else {
                bool ng = false;
                vector<ll> v(m);
                rep(j, m) {
                    ll num = x[j] - c[i][j] * 100 * t[i];
                    // if(flag and i == n - 1) cout << num << " " << (ll(100) - t[i]) << endl;
                    if(num % (ll(100) - t[i])) {
                        ng = true;
                        break;
                    }
                    num /= (ll(100) - t[i]);
                    v[j] = num;
                    // if(flag and i == n - 1) cout << v[j] << " ";
                }
                // if(flag and i == n - 1) cout <<endl;
                if(!ng) {
                    if(st.count(v)) {
                        cout << "Yes" << endl;
                        exit(0);
                    }
                }
            }

            vector<ll> v(m);
            rep(j, m) {
                v[j] = t[i] * c[i][j];
            }
            st.insert(v);
        }
    };
    solve();
    reverse(all(c));
    reverse(all(t));
    solve(1);
    cout << "No" << endl;
    return 0;
}
0