QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318356#3558. Constellation 3toj0 2ms7972kbC++201.2kb2024-01-31 09:12:332024-01-31 09:12:34

Judging History

This is the latest submission verdict.

  • [2024-01-31 09:12:34]
  • Judged
  • Verdict: 0
  • Time: 2ms
  • Memory: 7972kb
  • [2024-01-31 09:12:33]
  • Submitted

answer

// S2OJ Submission #1197 @ 1706663552162
#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));
	}
	Bcj L(N), R(N);
	Szsz cost(N);
	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;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7972kb

input:

297
296 275 40 154 200 77 201 106 133 163 127 268 225 154 27 202 272 176 133 116 151 11 262 281 188 152 249 53 133 106 160 62 104 210 54 201 184 110 199 217 155 193 168 239 277 22 230 187 201 14 85 100 159 129 69 241 150 10 20 263 285 76 219 52 40 241 126 182 23 55 243 145 203 163 251 243 13 292 249...

output:

1784273

result:

wrong answer 1st lines differ - expected: '4354552', found: '1784273'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%