結果
| 問題 | No.60 魔法少女 |
| コンテスト | |
| ユーザー |
myanta
|
| 提出日時 | 2017-05-11 03:24:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,067 bytes |
| 記録 | |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 44,032 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-09-15 07:26:38 |
| 合計ジャッジ時間 | 9,738 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d%d%d", &ene[i].x, &ene[i].y, &ene[i].hp);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:40:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
using namespace std;
struct enemy_t
{
int x, y, hp, f;
};
vector<enemy_t> ene;
vector<vector<enemy_t*> > ene_h, ene_v;
int main(void)
{
int i, j, n, k;
int x, y, w, h, d;
int s, e, ans;
while(scanf("%d%d", &n, &k)==2)
{
ene_h.clear();
ene_v.clear();
ene_h.resize(1001);
ene_v.resize(1001);
ene.resize(n);
for(i=0;i<n;i++)
{
scanf("%d%d%d", &ene[i].x, &ene[i].y, &ene[i].hp);
ene[i].f=-1;
ene_h[ene[i].x+500].push_back(&ene[i]);
ene_v[ene[i].y+500].push_back(&ene[i]);
}
for(i=0;i<k;i++)
{
scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
s=max(x, -500);
e=min(x+w, 500);
for(j=s;j<=e;j++)
{
for(auto t: ene_h[j+500])
{
t->f=i;
}
}
s=max(y, -500);
e=min(y+h, 500);
for(j=s;j<=e;j++)
{
for(auto t: ene_v[j+500])
{
if(t->f!=i) continue;
t->hp-=d;
}
}
}
ans=0;
for(i=0;i<n;i++)
{
if(ene[i].hp>0) ans+=ene[i].hp;
}
/*
for(auto t: ene) printf("%d ", t.hp);
printf("\n");
*/
printf("%d\n", ans);
}
return 0;
}
myanta