結果

問題 No.2644 Iro Iro-Iro
ユーザー KumaTachiRen
提出日時 2024-02-19 23:12:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 1,882 bytes
コンパイル時間 4,562 ms
コンパイル使用メモリ 258,180 KB
最終ジャッジ日時 2025-02-19 17:39:05
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  }
  return os;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

using mint = modint998244353;
using vm = vector<mint>;
using vvm = vector<vm>;
inline ostream &operator<<(ostream &os, const mint x) { return os << x.val(); };

void solve() {
  const int d = 101;
  const int d3 = d * d * d;
  int n, m;
  cin >> n >> m;
  vm f(d3, 0);
  rep(i, 0, n) {
    int a, b, c;
    cin >> a >> b >> c;
    f[a + b * d + c * d * d] += 1;
  }
  vm g(d3);
  rep(i, 0, d3) g[i] = f[d3 - 1 - i];
  f = convolution(f, g);
  int ans = 0;
  rep(i, 0, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x = x + y * d + z * d * d;
    int v = 2 * n - (int)(f[x + d3 - 1].val());
    chmax(ans, v);
  }
  cout << ans << "\n";
}

int main() {
  int t = 1;
  // cin >> t;
  while (t--) solve();
}
0