結果

問題 No.2684 折々の色
ユーザー tnakao0123tnakao0123
提出日時 2024-04-26 15:52:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 1,856 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 66,176 KB
実行使用メモリ 34,188 KB
最終ジャッジ日時 2024-04-26 15:52:53
合計ジャッジ時間 16,477 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
15,500 KB
testcase_01 AC 6 ms
15,496 KB
testcase_02 AC 7 ms
15,492 KB
testcase_03 AC 7 ms
15,364 KB
testcase_04 AC 7 ms
15,500 KB
testcase_05 AC 6 ms
15,368 KB
testcase_06 AC 6 ms
15,496 KB
testcase_07 AC 6 ms
15,496 KB
testcase_08 AC 6 ms
15,496 KB
testcase_09 AC 6 ms
15,496 KB
testcase_10 AC 6 ms
15,368 KB
testcase_11 AC 163 ms
26,508 KB
testcase_12 AC 104 ms
21,508 KB
testcase_13 AC 183 ms
25,740 KB
testcase_14 AC 96 ms
22,028 KB
testcase_15 AC 109 ms
22,532 KB
testcase_16 AC 28 ms
17,544 KB
testcase_17 AC 97 ms
21,000 KB
testcase_18 AC 174 ms
27,016 KB
testcase_19 AC 210 ms
29,064 KB
testcase_20 AC 135 ms
23,048 KB
testcase_21 AC 42 ms
18,568 KB
testcase_22 AC 191 ms
27,528 KB
testcase_23 AC 142 ms
24,200 KB
testcase_24 AC 65 ms
19,720 KB
testcase_25 AC 97 ms
20,488 KB
testcase_26 AC 195 ms
27,012 KB
testcase_27 AC 113 ms
21,000 KB
testcase_28 AC 141 ms
24,068 KB
testcase_29 AC 355 ms
33,676 KB
testcase_30 AC 346 ms
33,928 KB
testcase_31 AC 343 ms
34,188 KB
testcase_32 AC 355 ms
33,924 KB
testcase_33 AC 364 ms
33,928 KB
testcase_34 AC 342 ms
34,060 KB
testcase_35 AC 338 ms
34,056 KB
testcase_36 AC 353 ms
33,928 KB
testcase_37 AC 346 ms
34,052 KB
testcase_38 AC 374 ms
34,056 KB
testcase_39 AC 376 ms
34,180 KB
testcase_40 AC 382 ms
34,184 KB
testcase_41 AC 374 ms
34,184 KB
testcase_42 AC 371 ms
34,060 KB
testcase_43 AC 384 ms
34,184 KB
testcase_44 AC 366 ms
34,056 KB
testcase_45 AC 370 ms
34,180 KB
testcase_46 AC 394 ms
34,184 KB
testcase_47 AC 6 ms
15,496 KB
testcase_48 AC 6 ms
15,620 KB
testcase_49 AC 6 ms
15,496 KB
testcase_50 AC 7 ms
15,496 KB
testcase_51 AC 8 ms
15,496 KB
testcase_52 AC 6 ms
15,496 KB
testcase_53 AC 6 ms
15,500 KB
testcase_54 AC 6 ms
15,368 KB
testcase_55 AC 6 ms
15,496 KB
testcase_56 AC 6 ms
15,500 KB
testcase_57 AC 7 ms
15,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2684.cc:  No.2684 折々の色 - yukicoder
 */

#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 10;

/* typedef */

typedef vector<int> vi;
typedef pair<vi,int> pvii;

/* global variables */

vi cvs[MAX_N];
int ts[MAX_N];
pvii ps[MAX_N];

/* subroutines */

void readv(int m, vi &v) {
  v.resize(m);
  for (int i = 0; i < m; i++) scanf("%d", &v[i]);
}

void subv(vi &a, vi &b) {
  for (int i = 0; i < a.size(); i++) a[i] -= b[i];
}

void mulv(vi &a, int b) { for (auto &u: a) u *= b; }

bool divv(vi &a, int b) {
  for (auto &u: a) {
    if (u % b != 0) return false;
    u /= b;
  }
  return true;
}

void printv(vi &a) { for (auto &u: a) printf(" %d", u); putchar('\n'); }

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  // ti/100*cik+(1-ti/100)*tj/100*cjk = xk
  // -> ti*cik+(1-ti/100)*tj*cjk = 100*xk
  // let ti*cik=>tcik,
  // -> tcik+(1-ti/100)tcjk = 100*xk
  // -> (1-ti/100)tcjk=100*xk-tcik
  // -> tcjk = (100*xk-tcik)*100/(100-ti)

  vi xv;
  readv(m, xv);
  mulv(xv, 100);

  for (int i = 0; i < n; i++) {
    readv(m, cvs[i]);
    scanf("%d", ts + i);
    mulv(cvs[i], ts[i]);
    if (ts[i] == 100 && cvs[i] == xv) { puts("Yes"); return 0; }
    ps[i] = {cvs[i], ts[i]};
  }
  sort(ps, ps + n);

  for (int i = 0; i < n; i++) {
    cvs[i] = ps[i].first, ts[i] = ps[i].second;
    //printv(cvs[i]);
  }
  
  for (int i = 0; i < n; i++) {
    if (ts[i] == 100) continue;

    vi fv(xv.begin(), xv.end());
    subv(fv, cvs[i]);
    mulv(fv, 100);
    if (divv(fv, 100 - ts[i])) {
      //printf(" i=%d:", i); printv(fv);
      int k = lower_bound(cvs, cvs + n, fv) - cvs;
      if (k < n && i != k && fv == cvs[k]) {
	puts("Yes"); return 0;
      }
    }
  }

  puts("No");
  return 0;
}
0