結果
問題 | No.2229 Treasure Searching Rod (Hard) |
ユーザー | ikefumy |
提出日時 | 2023-02-24 22:31:36 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,081 bytes |
コンパイル時間 | 2,155 ms |
コンパイル使用メモリ | 210,212 KB |
実行使用メモリ | 8,372 KB |
最終ジャッジ日時 | 2024-09-13 05:45:50 |
合計ジャッジ時間 | 7,033 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
8,372 KB |
testcase_01 | AC | 5 ms
8,172 KB |
testcase_02 | AC | 4 ms
8,004 KB |
testcase_03 | AC | 4 ms
8,108 KB |
testcase_04 | AC | 4 ms
8,000 KB |
testcase_05 | AC | 4 ms
7,996 KB |
testcase_06 | AC | 3 ms
8,040 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define db double #define pii pair<int,int> #define pll pair<ll,ll> #define ti3 tuple<int,int,int> #define int128 __int128_t #define pii128 pair<int128,int128> const int inf = 1 << 30; const ll linf = 1e18; const ll mod = 998244353; const db EPS = 1e-10; const db pi = acos(-1); template<class T> bool chmin(T& x, T y){ if(x > y) { x = y; return true; } else return false; } template<class T> bool chmax(T& x, T y){ if(x < y) { x = y; return true; } else return false; } // overload macro #define CAT( A, B ) A ## B #define SELECT( NAME, NUM ) CAT( NAME, NUM ) #define GET_COUNT( _1, _2, _3, _4, _5, _6 /* ad nauseam */, COUNT, ... ) COUNT #define VA_SIZE( ... ) GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 ) #define VA_SELECT( NAME, ... ) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) // rep(overload) #define rep( ... ) VA_SELECT(rep, __VA_ARGS__) #define rep2(i, n) for (decay_t<decltype(n)> i = 0; i < n; i++) #define rep3(i, a, b) for (decay_t<decltype(a)> i = a; i < b; i++) #define rep4(i, a, b, c) for (decay_t<decltype(a)> i = a; i < b; i += c) // rrep(overload) #define rrep( ... ) VA_SELECT(rrep, __VA_ARGS__) #define rrep2(i, n) for (decay_t<decltype(n)> i = n - 1; i >= 0; i--) #define rrep3(i, a, b) for (decay_t<decltype(a)> i = b - 1; i >= a; i--) #define rrep4(i, a, b, c) for (decay_t<decltype(a)> i = b - 1; i >= a; i -= c) // for_earh #define fore(e, v) for (auto&& e : v) // vector #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() template<class T> struct BIT{ int N; vector<T> bit; BIT(int n = 0) : N(n), bit(n + 1, 0) {} T sum(int i){ T s = 0; while(i > 0){ s += bit[i]; i -= i & -i; } return s; } void add(int i, T x){ while(i <= N){ bit[i] += x; i += i & -i; } } T sum(int l, int r){ return sum(r) - sum(l - 1); } }; template<long long mod> struct modint{ long long num; constexpr modint(long long x = 0) : num((x + mod) % mod) {} constexpr modint &operator += (const modint& rhs){ num = (num + rhs.num) % mod; return *this; } constexpr modint &operator -= (const modint& rhs){ num -= rhs.num; while(num < 0) num += mod; num %= mod; return *this; } constexpr modint &operator *= (const modint& rhs){ num = num * rhs.num % mod; return *this; } constexpr modint &operator /= (modint rhs){ int exp = mod - 2; while(exp > 0){ if(exp % 2){ *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } constexpr modint operator ++ (){ num = (num + 1) % mod; return *this; } constexpr modint operator ++ (int n){ (void)n; modint tmp = *this; ++(*this); return tmp; } constexpr modint operator -- (){ num = (num + mod - 1) % mod; return *this; } constexpr modint operator -- (int n){ (void)n; const modint tmp = *this; --(*this); return tmp; } void modpow(ll y){ modint tmp = (*this); (*this) = 1; while(y > 0){ if(y % 2){ (*this) *= tmp; } tmp *= tmp; y /= 2; } } constexpr modint operator + (const modint& rhs) const { return modint(*this) += rhs; } constexpr modint operator - (const modint& rhs) const { return modint(*this) -= rhs; } constexpr modint operator * (const modint& rhs) const { return modint(*this) *= rhs; } constexpr modint operator / (const modint& rhs) const { return modint(*this) /= rhs; } friend ostream &operator << (ostream& lhs, const modint& rhs){ return lhs << rhs.num; } friend istream &operator >> (istream& lhs, modint& rhs){ lhs >> rhs.num; return lhs; } }; #define mint modint<mod> mint modpow(mint x, ll y){ if(y == 0) return 1; mint e = modpow(x, y / 2); e = e * e; return e * (y % 2 == 0 ? 1 : x); } mint op(mint a, mint b) { return a + b; } int H, W, K; vector<ti3> q[200010]; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); cin >> H >> W >> K; rep (i, K) { int x, y, v; cin >> x >> y >> v; int rx = x + y, ry = x - y + W; q[rx].emplace_back(0, ry, v); } rep (i, 1, H + 1) rep (j, 1, W + 1) { int rx = i + j, ry = i - j + W; q[rx].emplace_back(1, ry, 0); } mint ans = 0; int N = H + W + 10; BIT<mint> st(N); rrep (i, 2, H + W + 1) { for (auto& [s, ry, v] : q[i]) { if (!s) st.add(ry, v); else ans += st.sum(ry, N); } } cout << ans << "\n"; }