結果
| 問題 | No.60 魔法少女 |
| コンテスト | |
| ユーザー |
vain0
|
| 提出日時 | 2015-06-23 11:24:56 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,117 bytes |
| 記録 | |
| コンパイル時間 | 804 ms |
| コンパイル使用メモリ | 88,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 17:09:06 |
| 合計ジャッジ時間 | 7,742 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:68:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%d %d %d", &x, &y, &hp);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:78:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
78 | 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>> buckets;
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 ) {
if ( e.hp >= 0 ) { e.hp -= a.d; }
}
++it; continue;
}
}
signed main() {
int n, k;
scanf("%d %d", &n, &k);
buckets.resize(MAX_X / BX + 5);
for ( auto& b : buckets ) {
b.reserve(n / buckets.size());
}
rep(ie, n) {
int x, y, hp;
scanf("%d %d %d", &x, &y, &hp);
x += 500; y += 500;
buckets[x / BX].push_back(Enemy {x, y, hp});
}
for ( auto& b : buckets ) {
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<int>((a.x + a.w + 1 + BX - 1) / BX, buckets.size())) {
deal(buckets[i], a);
}
}
ll total = 0;
for ( auto& b : buckets ) {
for ( auto& e : b ) {
if ( e.hp > 0 ) { total += e.hp; }
}
}
cout << total << endl;
return 0;
}
vain0