QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328133#8046. Rock-Paper-Scissors PyramidPetroTarnavskyi#Compile Error//C++202.2kb2024-02-15 17:31:142024-02-15 17:31:18

Judging History

你现在查看的是最新测评结果

  • [2024-02-15 17:31:18]
  • 评测
  • [2024-02-15 17:31:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const db EPS = 1e-9;
const db INF = 1e47;

vector<pair<db, LL>> compress(vector<pair<db, LL>> vec)
{
	sort(ALL(vec));
	vector<pair<db, LL>> res;
	for (auto [p, c] : vec)
	{
		if (res.empty() || abs(res.back().F - p) > EPS)
		{
			res.PB({p, c});
		}
		else
		{
			res.back().S += c;
		}
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<pair<db, LL>> vec(n);
	for (auto& [p, c] : vec)
		cin >> p >> c;
	vec = compress(vec);
	n = SZ(vec);
	for (auto [p, c] : vec)
		cout << p << " " << c << "\n";
	cout << "-----\n";
	vector<LL> sx[2];
	vector<db> sxx[2];
	FOR(j, 0, 2)
	{
		sx[j].resize(n + 1);
		sxx[j].resize(n + 1);
		FOR(i, 0, n)
		{
			auto& [p, c] = vec[i];
			sx[j][i + 1] = sx[j][i] + c;
			db x = abs(1 - p) < EPS ? INF : 1 / (1 - p);
			sxx[j][i + 1] = sx[j][i] * x;
			p = 1 - p;
		}
		reverse(ALL(vec));
	}
	reverse(ALL(sx[1]));
	reverse(ALL(sxx[1]));
	FOR(k, 0, 2)
	{
		FOR(i, 0, n + 1)
		{
			cout << sx[k][i] << " ";
		}
		cout << endl;
		FOR(i, 0, n + 1)
		{
			cout << sxx[k][i] << " ";
		}
		cout << endl;
	}
	db ans = 0;
	FOR(k, 0, 2)
	{
		FOR(j, 0, n + 1)
		{
			int i = lower_bound(ALL(sxx[k]), sxx[k ^ 1][j]) - sxx[k].begin() - 1;
			i = min(i, j);
			if (i >= 0)
			{
				ans = max(ans, sx[k][i] + sx[k ^ 1][j] - sxx[k ^ 1][j]);
			}
		}
		FOR(l, 0, 2)
		{
			reverse(ALL(sx[l]));
			reverse(ALL(sxx[l]));
		}
	}
	cout << ans << "\n";
	return 0;
}
0.000000000000000 10
1.000000000000000 15
-----
0 10 25 
0.000000000000000 0.000000000000000 1000000000000000043845843045076197354634047651840.000000000000000 
25 15 0 
1499999999999999984639126153007614336162066333696.000000000000000 0.000000000000000 0.000000000000000 
0.000000000000000

Details

answer.code:107:1: error: expected unqualified-id before numeric constant
  107 | 0.000000000000000 10
      | ^~~~~~~~~~~~~~~~~