QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#374875#8309. MountainPetroTarnavskyi#Compile Error//C++201.5kb2024-04-02 19:05:232024-04-02 19:05:24

Judging History

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

  • [2024-04-02 19:05:24]
  • 评测
  • [2024-04-02 19:05:23]
  • 提交

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 int LEN = 1 << 14;
const int LOG = 47;
int dp[LOG][LEN];

const int N = 40'447;
VI g[N];
int q[N];
int ans[N];
int c[N];
int val[N];
int idx[N];
int cnt[N];
set<int> free;
int sz = 1;

void recal(int i, int j, int v)
{
	dp[i].clear();
	FOR (k, 0, LEN)
	{
		dp[i][k] = min(dp[j][k], dp[j][k ^ c[v]] + val[v]);
	}
}

void dfsSZ(int v)
{
	cnt[v] = 1;
	for (auto to : g[v])
	{
		dfsSZ(to);
		cnt[v] += cnt[to];
	}
}

void dfsSolve(int v)
{
	sort(ALL(g[v]), [&](int i, int j)
	{
		return cnt[i] < cnt[j];
	});
	int id = idx[v];
	FOR (i, 0, SZ(g[v]) - 1)
	{
		int to = g[v][i];
		idx[to] = *free.begin();
		free.erase()
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	stack<int> s;
	s.push(0);
	FOR (i, 0, n)
	{
		string t;
		cin >> t;
		if (t == "ADD")
		{
			q[i] = sz;
			cin >> c[sz] >> v[sz];
			g[s.top()].PB(sz);
			s.push(sz);
			sz++;			
		}
		else
			s.pop();
	}
	idx[0] = 0;
	FOR (i, 1, LOG)
		free.insert(i);
	dfsSZ(0);
	dfsSolve(0);
	FOR (i, 0, n)
	{
		cout << ans[q[i]] << '\n';
	}
	
	return 0;
}

詳細信息

answer.code:31:10: error: ‘std::set<int> free’ redeclared as different kind of entity
   31 | set<int> free;
      |          ^~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:565:13: note: previous declaration ‘void free(void*)’
  565 | extern void free (void *__ptr) __THROW;
      |             ^~~~
answer.code: In function ‘void recal(int, int, int)’:
answer.code:36:15: error: request for member ‘clear’ in ‘dp[i]’, which is of non-class type ‘int [16384]’
   36 |         dp[i].clear();
      |               ^~~~~
answer.code: In function ‘void dfsSolve(int)’:
answer.code:63:33: error: request for member ‘begin’ in ‘free’, which is of non-class type ‘void(void*) noexcept’
   63 |                 idx[to] = *free.begin();
      |                                 ^~~~~
answer.code:64:22: error: request for member ‘erase’ in ‘free’, which is of non-class type ‘void(void*) noexcept’
   64 |                 free.erase()
      |                      ^~~~~
answer.code: In function ‘int main()’:
answer.code:84:41: error: ‘v’ was not declared in this scope
   84 |                         cin >> c[sz] >> v[sz];
      |                                         ^
answer.code:94:22: error: request for member ‘insert’ in ‘free’, which is of non-class type ‘void(void*) noexcept’
   94 |                 free.insert(i);
      |                      ^~~~~~