結果

問題 No.2684 折々の色
ユーザー udon1206
提出日時 2024-03-20 21:48:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 892 ms / 2,000 ms
コード長 2,540 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 207,580 KB
最終ジャッジ日時 2025-02-20 08:58:15
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;
using std::cin;
using std::cout;
using std::endl;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

constexpr int inf = (int)1e9 + 7;
constexpr long long INF = 1LL << 60;

void solve()
{
    int n, m;
    cin >> n >> m;
    std::vector<ll> X(m);
    for (int i = 0; i < m; i++)
    {
        cin >> X[i];
        X[i] *= 10000;
    }
    std::vector C(n, std::vector<ll>(m));
    std::vector<ll> 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 _ = 0; _ < 2; _++)
    {
        std::set<std::vector<ll>> s;
        std::vector<ll> v(m);
        for (int i = 0; i < n; i++)
        {
            bool ok = true;
            if (T[i] != 100)
            {
                for (int j = 0; j < m; j++)
                {
                    v[j] = X[j] - T[i] * 100 * C[i][j];
                    if (v[j] % (100 - T[i]) != 0)
                    {
                        ok = false;
                        break;
                    }
                    v[j] /= 100 - T[i];
                }
                if (ok and s.count(v))
                {
                    cout << "Yes"
                         << "\n";
                    return;
                }
            }
            else
            {
                bool ok = true;
                for (int j = 0; j < m; j++)
                {
                    if (C[i][j] * 10000 != X[j])
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    cout << "Yes"
                         << "\n";
                    return;
                }
            }

            for (int j = 0; j < m; j++)
            {
                v[j] = T[i] * C[i][j];
            }
            s.emplace(v);
        }
        std::reverse(T.begin(), T.end());
        std::reverse(C.begin(), C.end());
    }
    cout << "No"
         << "\n";
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int kkt = 1;
    // cin >> kkt;
    while (kkt--)
    {
        solve();
    }
}
0