結果
問題 | No.1490 スライムと爆弾 |
ユーザー | sgsw |
提出日時 | 2021-04-30 03:06:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 263 ms / 2,000 ms |
コード長 | 3,558 bytes |
コンパイル時間 | 1,946 ms |
コンパイル使用メモリ | 212,604 KB |
実行使用メモリ | 42,084 KB |
最終ジャッジ日時 | 2024-07-18 02:57:50 |
合計ジャッジ時間 | 6,731 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
34,816 KB |
testcase_01 | AC | 22 ms
34,816 KB |
testcase_02 | AC | 22 ms
34,816 KB |
testcase_03 | AC | 23 ms
34,816 KB |
testcase_04 | AC | 22 ms
35,072 KB |
testcase_05 | AC | 22 ms
34,816 KB |
testcase_06 | AC | 23 ms
34,816 KB |
testcase_07 | AC | 22 ms
35,072 KB |
testcase_08 | AC | 22 ms
34,816 KB |
testcase_09 | AC | 23 ms
34,816 KB |
testcase_10 | AC | 23 ms
35,200 KB |
testcase_11 | AC | 23 ms
34,816 KB |
testcase_12 | AC | 21 ms
34,816 KB |
testcase_13 | AC | 127 ms
37,616 KB |
testcase_14 | AC | 149 ms
41,468 KB |
testcase_15 | AC | 82 ms
36,276 KB |
testcase_16 | AC | 119 ms
37,620 KB |
testcase_17 | AC | 71 ms
36,276 KB |
testcase_18 | AC | 150 ms
41,720 KB |
testcase_19 | AC | 132 ms
42,084 KB |
testcase_20 | AC | 101 ms
37,620 KB |
testcase_21 | AC | 64 ms
36,400 KB |
testcase_22 | AC | 136 ms
40,564 KB |
testcase_23 | AC | 22 ms
34,816 KB |
testcase_24 | AC | 22 ms
34,816 KB |
testcase_25 | AC | 165 ms
41,084 KB |
testcase_26 | AC | 165 ms
40,308 KB |
testcase_27 | AC | 169 ms
41,084 KB |
testcase_28 | AC | 121 ms
34,944 KB |
testcase_29 | AC | 120 ms
34,688 KB |
testcase_30 | AC | 263 ms
41,208 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define ALL(a) a.begin(),a.end() #define rep(i,n) for (int i = 0; i < n; i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rrep1(i, n) for (int i = (n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) template<class T> ostream& operator << (ostream &s, vector<T> &P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template <class T>bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;} template <class T>bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;} using P = pair<int,int>; const int inf = 1e18; template <class T>int count_smaller_than(vector<T> & V,T x){ auto itr = lower_bound(V.begin(),V.end(),x); return itr - V.begin(); } template <class T>int smaller_than(vector<T> & V,T x){ auto itr = lower_bound(V.begin(),V.end(),x); if (itr == V.begin()){return -inf;} return V[itr - V.begin() - 1]; } template<class T> vector<T> push(vector<T> & V){ vector<pair<T,int>> A; vector<T> res(V.size()); for (int i = 0; i < V.size(); i++){ A.push_back(P{V[i],i}); } sort(A.begin(),A.end()); T saved_val; int prev_idx = 1; for (int i = 0; i < V.size(); i++){ auto [val,idx] = A[i]; if (i == 0){res[idx] = 1;saved_val = val;prev_idx = 1;continue;} if (saved_val == val){res[idx] =prev_idx;continue;} else{saved_val = val;prev_idx++;res[idx] = prev_idx;continue;} } return res; } template <class T = int>T gcd(T a, T b){return (b == 0) ? a : gcd(b, a % b);} template <class T = int>T lcm(T a, T b){return a / gcd(a, b) * b;} template<class T = int>T powMod(T x, T k, T m) {if (k == 0){return (T)1;}if (k % 2 == 0) {return powMod(x*x % m, k/2, m);}else{return x*powMod(x, k-1, m) % m;}} template <class T = int>T extgcd(T a,T b,T &x,T &y){T g = a;x = 1;y = 0;if (b != 0) {g = extgcd(b, a % b, y, x), y -= (a / b) * x;}return g;} template<class T = int> T invMod(T a,T m){T x,y;if (extgcd(a, m, x, y) == 1) {return (x + m) % m;}else{return -1;}} const int MAXN = 2010; vector<vector<int>> C(MAXN,vector<int>(MAXN,0)); int field_damamge_sum(int rl,int rr,int cl,int cr){ return C[rr][cr] + C[rl - 1][cl - 1] - C[rl - 1][cr] - C[rr][cl - 1]; } void bomb_update(int rl,int rr,int cl,int cr,int d){ C[rl][cl] += d; C[rl][cr + 1] -= d; C[rr + 1][cl] -= d; C[rr + 1][cr + 1] += d; return; } using slime = tuple<int,int,int,int,int>; signed main(){ int h,w,n,m; cin>>h>>w>>n>>m; vector<slime> Slimes; rep(i,n){ int a,b,c,d,e; cin>>a>>b>>c>>d>>e; auto s = slime{a,b,c,d,e}; Slimes.push_back(s); } rep(i,m){ int x,y,b,c; cin>>x>>y>>b>>c; int rl = max(1ll,x - b); int rr = min(h,x + b); int cl = max(1ll,y - b); int cr = min(w,y + b); bomb_update(rl,rr,cl,cr,c); } rep1(i,h)rep1(j,w){ int x = C[i][j]; C[i][j + 1] += x; } rep1(i,h)rep1(j,w){ int x = C[i][j]; C[i + 1][j] += x; } rep1(i,h)rep1(j,w){ int x = C[i][j]; C[i][j + 1] += x; } rep1(i,h)rep1(j,w){ int x = C[i][j]; C[i + 1][j] += x; } int ans = 0; for (auto s : Slimes){ auto [rl,rr,cl,cr,h] = s; //cout << field_damamge_sum(rl,rr,cl,cr) << endl; if (field_damamge_sum(rl,rr,cl,cr) < h)ans++; } cout << ans << endl; return 0; }