QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#166608#149. Peruzlt0 171ms36060kbC++142.2kb2023-09-06 15:31:242023-09-06 15:31:26

Judging History

你现在查看的是测评时间为 2023-09-06 15:31:26 的历史记录

  • [2024-09-10 16:44:10]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:173ms
  • 内存:37160kb
  • [2023-09-06 15:31:26]
  • 评测
  • 测评结果:0
  • 用时:171ms
  • 内存:36060kb
  • [2023-09-06 15:31:24]
  • 提交

answer

#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;

const int maxn = 2500100;
const ll mod = 1000000007;

namespace SGT {
	ll mn[maxn << 2], tag[maxn << 2];
	
	inline void init() {
		mems(mn, 0x3f);
	}
	
	inline void pushup(int x) {
		mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
	}
	
	inline void pushdown(int x) {
		if (!tag[x]) {
			return;
		}
		mn[x << 1] += tag[x];
		mn[x << 1 | 1] += tag[x];
		tag[x << 1] += tag[x];
		tag[x << 1 | 1] += tag[x];
		tag[x] = 0;
	}
	
	void update(int rt, int l, int r, int ql, int qr, ll x) {
		if (ql <= l && r <= qr) {
			mn[rt] += x;
			tag[rt] += x;
			return;
		}
		pushdown(rt);
		int mid = (l + r) >> 1;
		if (ql <= mid) {
			update(rt << 1, l, mid, ql, qr, x);
		}
		if (qr > mid) {
			update(rt << 1 | 1, mid + 1, r, ql, qr, x);
		}
		pushup(rt);
	}
	
	void modify(int rt, int l, int r, int x, ll y) {
		if (l == r) {
			mn[rt] = y;
			return;
		}
		pushdown(rt);
		int mid = (l + r) >> 1;
		(x <= mid) ? modify(rt << 1, l, mid, x, y) : modify(rt << 1 | 1, mid + 1, r, x, y);
		pushup(rt);
	}
	
	ll query(int rt, int l, int r, int ql, int qr) {
		if (ql <= l && r <= qr) {
			return mn[rt];
		}
		pushdown(rt);
		int mid = (l + r) >> 1;
		ll res = 1e18;
		if (ql <= mid) {
			res = min(res, query(rt << 1, l, mid, ql, qr));
		}
		if (qr > mid) {
			res = min(res, query(rt << 1 | 1, mid + 1, r, ql, qr));
		}
		return res;
	}
}

ll f[maxn], pw[maxn];
int stk[maxn], top;

int solve(int n, int m, int* a) {
	pw[0] = 1;
	for (int i = 1; i <= n; ++i) {
		pw[i] = pw[i - 1] * 23 % mod;
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		while (top && a[stk[top]] <= a[i]) {
			SGT::update(1, 1, n, stk[top - 1] + 1, stk[top], a[i] - a[stk[top]]);
			--top;
		}
		stk[++top] = i;
		SGT::modify(1, 1, n, i, f[i - 1] + a[i]);
		f[i] = SGT::query(1, 1, n, max(1, i - m + 1), i);
		ans = (ans + f[i] % mod * pw[n - i] % mod) % mod;
	}
	return ans;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 9820kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

763827715

result:

wrong answer 1st lines differ - expected: '559335223', found: '763827715'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 171ms
memory: 36060kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

291941679

result:

wrong answer 1st lines differ - expected: '677928817', found: '291941679'

Subtask #3:

score: 0
Time Limit Exceeded

Test #34:

score: 0
Time Limit Exceeded

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:


result: