結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
vain0
|
| 提出日時 | 2015-06-23 10:25:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,032 bytes |
| コンパイル時間 | 2,009 ms |
| コンパイル使用メモリ | 87,740 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 17:05:07 |
| 合計ジャッジ時間 | 8,536 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:66:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | scanf("%d %d %d", &e.x, &e.y, &e.hp);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:76:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
76 | scanf("%d %d %d %d %d", &a.x, &a.y, &a.w, &a.h, &a.d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cassert>
#include <functional>
#include <set>
#include <ctime>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#ifndef ONLINE_JUDGE //POJ
# include <complex>
# include <random>
# include <array>
# define mkt make_tuple
# define empb emplace_back
#endif
#ifdef _LOCAL
# include "for_local.h"
#endif
using namespace std;
typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define mkp make_pair
#define all(_X) (_X).begin(), (_X).end()
inline int scani() { int n; scanf("%d", &n); return n; }
int n, k;
struct Enemy { int x, y, hp; };
struct Attack { int x, y, w, h, d; };
int const MAX_X = 1001, MAX_Y = 1001;
int const BX = 32; //1つのバケツがカバーするxの幅
vector<vector<Enemy>> backets;
bool operator < (Enemy const& lhs, Enemy const& rhs) {
return (lhs.y - rhs.y) < 0;
}
void deal(vector<Enemy>& b, Attack& a) {
auto&& lb = lower_bound(all(b), Enemy{0, a.y, 0});
auto&& ub = upper_bound(all(b), Enemy{0, a.y + a.h + 1, 0});
for(auto it = lb; it != ub; ) {
auto& e = *it;
if ( a.x <= e.x && e.x <= a.x + a.w) {
e.hp -= a.d;
//if ( e.hp <= 0 ) {++it; continue;}
}
++it; continue;
}
}
signed main() {
int n, k;
scanf("%d %d", &n, &k);
backets.resize(MAX_X / BX + 3);
rep(i, n) {
Enemy e;
scanf("%d %d %d", &e.x, &e.y, &e.hp);
e.x += 500; e.y += 500;
backets[e.x / BX].emplace_back(e);
}
for(auto& b : backets) {
std::sort(all(b));
}
rep(ia, k) {
Attack a;
scanf("%d %d %d %d %d", &a.x, &a.y, &a.w, &a.h, &a.d);
a.x += 500; a.y += 500;
repi(i, a.x/BX, (min(MAX_X, a.x + a.w + 1))/BX + 1) {
deal(backets[i], a);
}
}
int total = 0;
for ( auto& b : backets ) {
for ( auto& e : b ) {
if ( e.hp > 0 ) total += e.hp;
}
}
cout << total << endl;
return 0;
}
vain0