QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74674#2271. High-Tech DetectiveXKErrorRE 2ms13856kbC++141.4kb2023-02-03 11:20:422023-02-03 11:20:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-03 11:20:43]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:13856kb
  • [2023-02-03 11:20:42]
  • 提交

answer

#include <bits/stdc++.h>

#define maxn 505
#define mod 1000000007

using namespace std;

int n;

int f[maxn][maxn][maxn];

int a[maxn];
char s[maxn][5];

int vis[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; i++) {
		scanf("%s%d", s[i], &a[i]);
		if (a[i]) ++vis[a[i]];
	}
	f[0][0][0] = 1;
	for (int i = 1; i <= n * 2; i++) {
		if (vis[a[i]] == 2) {
			for (int j = 0; j <= n; j++) 
				for (int k = 0; k <= n; k++) f[i][j][k] = f[i - 1][j][k];
			continue;
		}
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				if (s[i][0] == 'I') {
					if (a[i] == 0) f[i][j][k] = (j ? f[i - 1][j - 1][k] : 0);
					else f[i][j][k] = (k ? f[i - 1][j][k - 1] : 0);
				}
				else {
					if (a[i] == 0) f[i][j][k] = (1ll * f[i - 1][j + 1][k] * (j + 1) % mod + 1ll * f[i - 1][j][k + 1] * (k + 1) % mod) % mod;
					else f[i][j][k] = 1ll * f[i - 1][j + 1][k] * (j + 1) % mod;
				}
				
			}
//			if (s[i][0] == 'I' && j > 0) f[i][j] = f[i - 1][j - 1];
//			else if (s[i][0] == 'O') {
//				if (a[i] > 0) f[i][j] = f[i - 1][j + 1];
//				else f[i][j] = 1ll * f[i - 1][j + 1] * (j + 1) % mod;
//			}
//			cout<<f[i][j]<<" ";
		}
//		puts("");
	}
	int res = f[n * 2][0][0];
	int cnt = 0;
	for (int i = 1; i <= n; i++) cnt += (vis[i] == 0);
	while (cnt) {
		res = 1ll * res * cnt % mod;
		--cnt;
	}
	printf("%d\n", res);
//	printf("%d\n", f[n * 2][0][0]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3664kb

input:

4
I 1
I 0
O 0
I 0
O 2
I 4
O 0
O 4

output:

3

result:

ok single line: '3'

Test #2:

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

input:

3
I 0
I 0
I 0
O 0
O 0
O 0

output:

36

result:

ok single line: '36'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

1
I 0
O 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

2
I 0
I 1
O 1
O 0

output:

1

result:

ok single line: '1'

Test #5:

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

input:

4
I 0
I 0
O 0
O 0
I 0
I 3
O 0
O 0

output:

24

result:

ok single line: '24'

Test #6:

score: 0
Accepted
time: 0ms
memory: 4024kb

input:

8
I 0
I 0
I 0
I 8
I 4
I 0
O 1
I 0
O 8
O 4
I 5
O 0
O 0
O 5
O 0
O 7

output:

576

result:

ok single line: '576'

Test #7:

score: 0
Accepted
time: 2ms
memory: 4880kb

input:

16
I 5
I 4
I 2
I 1
I 10
I 6
I 14
I 3
I 11
I 7
I 16
O 0
O 7
I 15
O 1
I 8
I 12
O 4
O 11
O 0
I 13
O 14
O 12
O 13
I 0
O 5
O 0
O 0
O 0
O 0
O 0
O 3

output:

2400

result:

ok single line: '2400'

Test #8:

score: 0
Accepted
time: 2ms
memory: 13856kb

input:

50
I 42
I 32
I 29
I 14
I 27
I 0
I 9
I 18
I 11
I 25
O 31
I 39
I 41
I 23
I 43
I 1
I 35
O 25
I 44
I 5
I 28
I 48
I 33
I 50
I 21
I 19
O 29
O 33
O 19
O 44
I 17
I 6
O 32
O 23
I 30
O 42
I 13
O 27
I 20
I 34
I 15
O 17
O 30
I 36
O 0
I 0
I 10
O 21
O 36
I 40
O 34
O 9
I 4
O 20
O 14
I 47
O 1
I 22
O 50
I 26
I 24
I ...

output:

2

result:

ok single line: '2'

Test #9:

score: -100
Runtime Error

input:

300
I 117
I 122
I 64
I 166
I 65
I 70
I 81
I 180
I 270
I 211
I 191
I 95
I 103
I 271
O 180
I 161
I 108
I 149
I 175
I 79
I 225
I 141
I 146
I 240
I 168
I 227
I 233
I 75
I 286
I 7
I 43
I 246
I 285
I 63
I 73
I 282
I 269
I 36
I 291
I 2
I 55
I 41
O 73
I 170
I 25
I 196
I 220
I 33
I 165
I 203
O 70
I 153
I 289...

output:


result: