結果

問題 No.60 魔法少女
ユーザー outlineoutline
提出日時 2021-02-03 00:54:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 2,950 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 135,788 KB
実行使用メモリ 11,920 KB
最終ジャッジ日時 2023-09-12 11:31:23
合計ジャッジ時間 3,896 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,380 KB
testcase_01 AC 5 ms
5,300 KB
testcase_02 AC 4 ms
5,352 KB
testcase_03 AC 5 ms
10,088 KB
testcase_04 AC 175 ms
11,688 KB
testcase_05 AC 111 ms
11,836 KB
testcase_06 AC 244 ms
11,836 KB
testcase_07 AC 180 ms
11,856 KB
testcase_08 AC 105 ms
11,796 KB
testcase_09 AC 51 ms
11,648 KB
testcase_10 AC 240 ms
11,724 KB
testcase_11 AC 14 ms
11,920 KB
testcase_12 AC 76 ms
11,800 KB
testcase_13 AC 274 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

constexpr int B = 32;
ll HP[1005][1005], lazy[35][35], xlazy[35][1005], ylazy[1005][35];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K, X, Y, W, H, D;
    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> X >> Y;
        X += 500; Y += 500;
        cin >> HP[X][Y];
    }
    for(int q = 0; q < K; ++q){
        cin >> X >> Y >> W >> H >> D;
        X += 500; Y += 500;
        int lx = X, rx = min(1000, X + W) + 1;
        while(lx < rx && lx % B != 0){
            int ly = Y, ry = min(1000, Y + H) + 1;
            while(ly < ry && ly % B != 0){
                HP[lx][ly++] -= D;
            }
            while(ly < ry && ry % B != 0){
                HP[lx][--ry] -= D;
            }
            for(int i = ly / B; i < ry / B; ++i){
                ylazy[lx][i] += D;
            }
            ++lx;
        }
        while(lx < rx && rx % B != 0){
            --rx;
            int ly = Y, ry = min(1000, Y + H) + 1;
            while(ly < ry && ly % B != 0){
                HP[rx][ly++] -= D;
            }
            while(ly < ry && ry % B != 0){
                HP[rx][--ry] -= D;
            }
            for(int i = ly / B; i < ry / B; ++i){
                ylazy[rx][i] += D;
            }
        }
        int ly = Y, ry = min(1000, Y + H) + 1;
        while(ly < ry && ly % B != 0){
            for(int i = lx / B; i < rx / B; ++i){
                xlazy[i][ly] += D;
            }
            ++ly;
        }
        while(ly < ry && ry % B != 0){
            --ry;
            for(int i = lx / B; i < rx / B; ++i){
                xlazy[i][ry] += D;
            }
        }
        for(int i = lx / B; i < rx / B; ++i){
            for(int j = ly / B; j < ry / B; ++j){
                lazy[i][j] += D;
            }
        }
    }
    ll ans = 0;
    for(int x = 0; x <= 1000; ++x){
        for(int y = 0; y <= 1000; ++y){
            ans += max(0LL, HP[x][y] - lazy[x / B][y / B] - xlazy[x / B][y] - ylazy[x][y / B]);
        }
    }
    cout << ans << endl;

    return 0;
}
0