結果

問題 No.2684 折々の色
ユーザー 👑 hos.lyric
提出日時 2024-03-20 22:43:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 404 ms / 2,000 ms
コード長 2,520 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 123,096 KB
実行使用メモリ 75,184 KB
最終ジャッジ日時 2024-09-30 08:48:42
合計ジャッジ時間 13,806 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N, M;
vector<Int> X;
vector<vector<Int>> C;
vector<Int> T;

bool solve() {
  vector<vector<Int>> D(N, vector<Int>(M));
  for (int u = 0; u < N; ++u) {
    for (int i = 0; i < M; ++i) {
      D[u][i] = T[u] * C[u][i];
    }
  }
  auto ds = D;
  sort(ds.begin(), ds.end());
  for (int u = 0; u < N; ++u) {
    if (T[u] == 100) {
      if (X == C[u]) {
        return true;
      }
    } else {
      bool ok = true;
      vector<Int> tar(M);
      for (int i = 0; i < M; ++i) {
        tar[i] = 10000 * X[i] - 100 * T[u] * C[u][i];
        ok = ok && (tar[i] % (100 - T[u]) == 0);
        tar[i] /= (100 - T[u]);
      }
// cerr<<u<<" "<<C[u]<<" "<<D[u]<<" "<<tar<<endl;
      if (ok && tar != D[u]) {
        auto it = lower_bound(ds.begin(), ds.end(), tar);
        if (it != ds.end() && *it == tar) {
          return true;
        }
      }
    }
  }
  return false;
}

int main() {
  for (; ~scanf("%d%d", &N, &M); ) {
    X.resize(M);
    for (int i = 0; i < M; ++i) {
      scanf("%lld", &X[i]);
    }
    C.assign(N, vector<Int>(M));
    T.resize(N);
    for (int u = 0; u < N; ++u) {
      for (int i = 0; i < M; ++i) {
        scanf("%lld", &C[u][i]);
      }
      scanf("%lld", &T[u]);
    }
    
    const bool ans = solve();
    puts(ans ? "Yes" : "No");
  }
  return 0;
}
0