結果
| 問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-09 06:48:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,754 bytes |
| コンパイル時間 | 890 ms |
| コンパイル使用メモリ | 78,964 KB |
| 実行使用メモリ | 9,856 KB |
| 最終ジャッジ日時 | 2024-09-14 18:34:05 |
| 合計ジャッジ時間 | 3,553 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 30 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct iostream_init_struct
{
iostream_init_struct()
{
std::cin.tie(0);
std::ios::sync_with_stdio(false);
}
} iostream_init;
// index begins with 1
class BIT
{
public:
vector<long long> data;
const int msb_n;
BIT(int n) : data(n + 1), msb_n(1 << log(n)) {}
void add(int i, int v)
{
for (int x = i; x < data.size(); x += x & -x)
{
data[x] += v;
}
}
//long long sum(int i)
//{
// int ret = 0;
// for (int x = i; x > 0; x -= x & -x)
// {
// ret += data[x];
// }
// return ret;
//}
int lowerBound(long long v)
{
int x = 0;
for (int k = msb_n; k > 0; k /= 2)
{
if (x + k < data.size() && data[x + k] < v)
{
v -= data[x + k];
x += k;
}
}
return x + 1;
}
inline static int log(int n)
{
#ifdef __GNUC__
return std::__lg(n);
#else
int ret = 0;
while (n = n >> 1)
{
ret += 1;
}
return ret;
#endif
}
};
int n;
long long h;
int w;
// adding_data[i][]
// i: place
// first: time
// second: b (height)
vector<vector<pair<int, int>>> adding_data;
int main()
{
cin >> n >> w >> h;
adding_data = vector<vector<pair<int, int>>>(w + 2);
for (int i = 1; i <= n; ++i)
{
int a, b, x;
cin >> a >> b >> x;
adding_data[x].emplace_back(i, b);
adding_data[x + a].emplace_back(i, -b);
}
BIT bit(w);
int A_score = 0;
for (int x = 1; x <= w; ++x)
{
for (auto data : adding_data[x])
{
int time = data.first;
int add_height = data.second;
bit.add(time, add_height);
}
A_score += bit.lowerBound(h) & 1;
}
int B_score = w - A_score;
if (A_score > B_score)
cout << "A" << endl;
else if (A_score < B_score)
cout << "B" << endl;
else
cout << "DRAW" << endl;
}