QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#344897#3809. Wooden SignsPetroTarnavskyi#WA 1ms3880kbC++201.2kb2024-03-05 18:02:242024-03-05 18:02:24

Judging History

This is the latest submission verdict.

  • [2024-03-05 18:02:24]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3880kb
  • [2024-03-05 18:02:24]
  • Submitted

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 + 1)
		cin >> a[i];
		
	dp[0][a[0]] = 1;
	FOR (i, 1, n)
	{
		FOR (pos, 1, n + 2)
		{
			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 + 2)
	{
		ans = add(ans, dp[n - 1][i]);
	}
	cout << ans % mod << '\n';
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

5
2 6 5 1 4 3

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

17
7 16 14 9 11 4 6 3 8 5 12 10 18 15 1 2 17 13

output:

468

result:

ok single line: '468'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

50
13 31 46 33 50 9 25 40 32 23 38 2 37 4 16 7 5 22 39 44 15 3 29 43 14 45 8 12 51 11 10 28 26 21 24 17 6 20 36 48 30 35 42 41 1 27 47 34 49 18 19

output:

6183172

result:

ok single line: '6183172'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

45
10 38 6 14 44 20 13 12 2 37 5 41 19 40 31 33 23 29 27 45 24 46 9 3 42 18 43 39 35 15 1 32 25 36 16 30 26 22 17 28 8 11 7 4 21 34

output:

623448

result:

ok single line: '623448'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3844kb

input:

79
2 9 22 10 44 34 45 32 58 31 78 64 5 79 63 57 52 80 75 60 38 35 68 73 3 13 7 65 48 24 70 40 16 21 37 17 30 28 41 53 59 14 46 43 72 11 62 33 18 67 51 69 23 66 12 56 27 4 71 61 19 42 20 77 47 25 6 54 29 74 8 15 39 1 76 49 55 36 50 26

output:

343336744

result:

wrong answer 1st lines differ - expected: '343336771', found: '343336744'