QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#568363#9313. Make MaxreisentyanWA 0ms3484kbC++141.6kb2024-09-16 16:12:272024-09-16 16:12:27

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 16:12:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3484kb
  • [2024-09-16 16:12:27]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stdio.h>
#include<stack>
#include<list>
using namespace std;
#define ffp(x,y,z) for(int(x) = (y);(x)<=(z);(x++))
#define ffs(x,y,z) for(int(x) = (y);(x)>=(z);(x--))
#define pii pair<ll ,ll> 
#define ll long long int
#define endl '\n'
#define q_ qd()
const int iINF = 0x3f3f3f3f;
const ll lINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1000000007;
long long qd() {
	long long w = 1, c, ret;
	while ((c = getchar()) > '9' || c < '0')
		w = (c == '-' ? -1 : 1); ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		ret = ret * 10 + c - '0';
	return ret * w;
}

int num[200200];
struct N
{
	int va;
	int l;
	int r;
};
int l[200200];
int r[200200];
stack<N>st;

int main()
{
	int t = q_;
	while (t--)
	{
		int n = q_;
		ffp(i, 1, n)
		{
			num[i] = q_;
		}

		ffp(i, 1, n)
		{
			while (st.size() && st.top().va < num[i])
			{
				r[st.top().r] = i -st.top().r - 1;
				st.pop();
			}

			if (st.size() == 0)
			{
				st.push({ num[i],i,i });
				l[i] = i - 1;
				continue;
			}
			else
			{
				if (st.top().va == num[i])
				{
					l[i] = i - st.top().r-1;
					st.top().r = i;
				}
				else
				{
					l[i] = i - st.top().r - 1;
					st.push({ num[i],i,i });
				}
			}
		}

		while (st.size())
		{
			r[st.top().r] = n - st.top().r;
			st.pop();
		}
		ll ans = 0;
		ffp(i, 1, n)
		{
			ans += l[i] + r[i];
			cout << i << " " << l[i] << ' ' << r[i] << endl;
			l[i] = 0; r[i] = 0;
			num[i] = 0;
		}
		cout << ans << endl;
	}

	
	return 0;
}

詳細信息

Test #1:

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

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1 0 0
2 1 0
1
1 0 0
2 0 0
0
1 0 0
2 0 0
3 0 0
4 3 0
5 0 0
6 0 0
7 0 0
3
1 0 0
2 1 0
3 2 0
3

result:

wrong answer 3rd numbers differ - expected: '3', found: '0'