QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318357#3558. Constellation 3tojCompile Error//C++201.2kb2024-01-31 09:13:052024-01-31 09:13:05

Judging History

This is the latest submission verdict.

  • [2024-01-31 09:13:05]
  • Judged
  • [2024-01-31 09:13:05]
  • Submitted

answer

// S2OJ Submission #1198 @ 1706663584640
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 2e5 + 1;
int n, m, ans;
vector<int> z[N];
vector<pair<int, int>> st[N];

struct Bcj {
	 vector<int> fa;
	 Bcj(int num) : fa(num) {for (int i = 1; i <= n; ++i) fa[i] = i;}
	 int find(int x) {return x == fa[x] ? x : find(fa[x]);}
};

struct Szsz {
#define lowbit(i) i & -i
	vector<int> t;
	Szsz(int num) : t(num) {}
	int getsum(int i) {
		int sum = 0;
		for (; i; i -= lowbit(i))
			sum += t[i];
		return sum;
	}
	void add(int i, int x) {
		for (; i <= n; i += lowbit(i))
			t[i] += x;
	}
};

signed main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		z[a].push_back(i);
	}
	cin >> m;
	for (int i = 1; i <= m; ++i) {
		int x, y, c; cin >> x >> y >> c;
		st[y].push_back(make_pair(x, c));
	}
	for (int y = 1; y <= n; ++y) {
		for (auto star : st[y]) {
			int x = star.first, c = star.second;
			int C = cost.getsum(x);
			if (c <= C)
				ans += c;
			else {
				ans += C;
				cost.add(L.find(x)+1, c-C);
				cost.add(R.find(x)+1, C-c);
			}
		}
		for (int x : z[y])
			L.fa[x] = x-1, R.fa[x] = x+1;
	}
	cout << ans << endl;
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:47:33: error: ‘cost’ was not declared in this scope; did you mean ‘cosl’?
   47 |                         int C = cost.getsum(x);
      |                                 ^~~~
      |                                 cosl
answer.code:52:42: error: ‘L’ was not declared in this scope
   52 |                                 cost.add(L.find(x)+1, c-C);
      |                                          ^
answer.code:53:42: error: ‘R’ was not declared in this scope
   53 |                                 cost.add(R.find(x)+1, C-c);
      |                                          ^
answer.code:57:25: error: ‘L’ was not declared in this scope
   57 |                         L.fa[x] = x-1, R.fa[x] = x+1;
      |                         ^
answer.code:57:40: error: ‘R’ was not declared in this scope
   57 |                         L.fa[x] = x-1, R.fa[x] = x+1;
      |                                        ^