QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344891#3805. PromotionsPetroTarnavskyi#WA 1ms3600kbC++201.2kb2024-03-05 17:44:062024-03-05 17:44:07

Judging History

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

  • [2024-03-05 17:44:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-03-05 17:44:06]
  • 提交

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 mod = (1ll << 31) - 1;

int add(int a, int b)
{
	return (a + b) & mod;
}

int bigger(int a, int b)
{
	if (a > b)
		return 1;
	return -1;
}

const int N = 2047;
int dp[N][N];


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	VI a(n + 1);
	FOR (i, 0, n)
		cin >> a[i];
	dp[0][a[0]] = 1;
	FOR (i, 1, n)
	{
		FOR (pos, 1, n + 1)
		{
			if (dp[i - 1][pos] == 0)
				continue;
			if (bigger(a[i], pos) == bigger(a[i + 1], pos))
			{
				dp[i][pos] = add(dp[i][pos], dp[i - 1][pos]);
			}
			if (bigger(pos, a[i]) == bigger(a[i + 1], a[i]))
				dp[i][a[i]] = add(dp[i][a[i]], dp[i - 1][pos]);
		}
	}
	int ans = 0;
	FOR (i, 1, n + 1)
	{
		ans = add(ans, dp[n - 1][i]);
	}
	cout << ans << '\n';
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3600kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '2', found: '0'