結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-05 20:07:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,161 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 29,440 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:43 |
| 合計ジャッジ時間 | 1,597 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:9: error: ‘vector’ was not declared in this scope
14 | vector<tuple<int, int, int>> v;
| ^~~~~~
main.cpp:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
3 | #include <algorithm>
+++ |+#include <vector>
4 | using namespace std;
main.cpp:14:35: error: expected primary-expression before ‘>’ token
14 | vector<tuple<int, int, int>> v;
| ^~
main.cpp:14:38: error: ‘v’ was not declared in this scope
14 | vector<tuple<int, int, int>> v;
| ^
main.cpp:41:13: error: ‘tie’ was not declared in this scope
41 | tie(x, y, hp)=p;
| ^~~
main.cpp:4:1: note: ‘std::tie’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
3 | #include <algorithm>
+++ |+#include <tuple>
4 | using namespace std;
main.cpp:16:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | int x, y, hp; scanf("%d%d%d", &x, &y, &hp);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:21:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | int x, y, w, h, d; scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx=1001, maxy=1001;
int b[maxx+2][maxy+2];
int main()
{
int n, k;
while (~scanf("%d%d", &n, &k)) {
memset(b, 0, sizeof(b));
vector<tuple<int, int, int>> v;
while (n--) {
int x, y, hp; scanf("%d%d%d", &x, &y, &hp);
x+=500, y+=500;
v.emplace_back(x, y, hp);
}
while (k--) {
int x, y, w, h, d; scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
x+=500, y+=500;
#define min(a, b) (a<b?a:b)
int xx=min(x+w+1, maxx), yy=min(y+h+1, maxy);
b[x][y]-=d;
b[x][yy]+=d;
b[xx][y]+=d;
b[xx][yy]-=d;
}
for(int x=0;x<maxx;++x)
for(int y=1;y<maxy;++y)
b[x][y]+=b[x][y-1];
for(int x=1;x<maxx;++x)
for(int y=0;y<maxy;++y)
b[x][y]+=b[x-1][y];
int res=0;
for(auto& p: v) {
int x, y, hp;
tie(x, y, hp)=p;
if (hp+b[x][y]>0)
res+=hp+b[x][y];
}
printf("%d\n", res);
}
}
hogeover30