QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558376#8937. Stage: AgausscrabYarema#Compile Error//C++201.4kb2024-09-11 15:45:232024-09-11 15:45:24

Judging History

This is the latest submission verdict.

  • [2024-09-11 15:45:24]
  • Judged
  • [2024-09-11 15:45:23]
  • Submitted

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 vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

const int INF = 1e9;
const int N = 10;

bool ok[1 << N];
int dp[1 << N];

bool hasBit(int mask, int i)
{
	return (mask >> i) & 1;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	VI l(n), r(n);
	FOR(i, 0, n)
		cin >> l[i] >> r[i];
	VI w(n);
	for (int& wi : w)
		cin >> wi;
	FOR(i, 0, 1 << n)
	{
		dp[i] = -INF;
	}
	dp[0] = 0;
	ok[0] = true;
	FOR(mask, 0, 1 << n)
	{
		if (!ok[mask])
			continue;
		int nmask = ((1 << n) - 1) ^ mask;
		for (int submask = nmask; submask > 0; submask = (submask - 1) & nmask)
		{
			int sz = __builtin_popcount(submask);
			bool can = true;
			FOR(i, 0, n)
			{
				if (hasBit(submask, i))
					can &= l[i] <= sz && sz <= r[i];
			}
			if (can)
			{
				ok[mask | submask] = true;
				dp[mask | submask] = max(dp[mask | submask], dp[mask] + w[sz - 1]);
			}
		}
	}
	if (!ok[(1 << n) - 1])
		cout << "impossible\n";
	else
		cout << dp[(1 << n) - 1] << "\n";
	return 0;
}


4
3 4
2 2
3 4
1 4
5 -4 -5 -9 

詳細信息

answer.code:79:1: error: expected unqualified-id before numeric constant
   79 | 4
      | ^