結果

問題 No.1679 マスゲーム
ユーザー keijak
提出日時 2021-09-13 02:10:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 201,020 KB
最終ジャッジ日時 2025-01-24 13:24:12
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
  for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
using i64 = long long;

void print() { std::cout << "\n"; }
template<class T>
void print(const T &x) {
  std::cout << x << "\n";
}
template<typename Head, typename... Tail>
void print(const Head &head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}

struct Input {
  template<typename T>
  operator T() const {
    T x;
    std::cin >> x;
    return x;
  }
} in;

#ifdef MY_DEBUG
#include "debug_dump.hpp"
#else
#define DUMP(...)
#endif

using namespace std;

auto solve() {
  const int n = in;
  map<int, int> m0, m1;
  REP(i, n) {
    const int a = in, b = in, t = in;
    if (a == 0) {
      ++m0[b - t];
    } else {
      ++m1[b - t];
    }
  }
  i64 ans = 0;
  for (auto[k, c]: m0) {
    ans += i64(c) * m1[k];
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  print(solve());
}
0