Submission #882223

# Submission time Handle Problem Language Result Execution time Memory
882223 2023-12-02T20:02:12 Z rainboy The grade (info1cup18_thegrade) C
100 / 100
32 ms 5200 KB
#include <stdio.h>

#define N	100000
#define A	1000000
#define MD	1000000007

int vv[N + 1], ff[N + 1], gg[N + 1];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int main() {
	static int kk[A + 1];
	int n, q, cnt, v;
	long long sum;

	init();
	scanf("%d%d", &q, &n);
	cnt = 0, sum = 0, v = 1;
	while (q--) {
		int t, a;

		scanf("%d%d", &t, &a);
		if (t == 0)
			cnt++, sum += a, v = (long long) v * vv[++kk[a]] % MD;
		else
			cnt--, sum -= a, v = (long long) v * kk[a]-- % MD;
		printf("%lld\n", sum > n ? -1 : (long long) ff[n - sum + cnt] * gg[n - sum] % MD * v % MD);
	}
	return 0;
}

Compilation message

thegrade.c: In function 'main':
thegrade.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &q, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
thegrade.c:31:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%d%d", &t, &a);
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 24 ms 4568 KB Output is correct
3 Correct 28 ms 4956 KB Output is correct
4 Correct 24 ms 5048 KB Output is correct
5 Correct 24 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 25 ms 4956 KB Output is correct
3 Correct 25 ms 4956 KB Output is correct
4 Correct 26 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 24 ms 4568 KB Output is correct
7 Correct 28 ms 4956 KB Output is correct
8 Correct 24 ms 5048 KB Output is correct
9 Correct 24 ms 4944 KB Output is correct
10 Correct 2 ms 3416 KB Output is correct
11 Correct 25 ms 4956 KB Output is correct
12 Correct 25 ms 4956 KB Output is correct
13 Correct 26 ms 4956 KB Output is correct
14 Correct 3 ms 3416 KB Output is correct
15 Correct 24 ms 4956 KB Output is correct
16 Correct 24 ms 4948 KB Output is correct
17 Correct 24 ms 4860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 24 ms 4568 KB Output is correct
3 Correct 28 ms 4956 KB Output is correct
4 Correct 24 ms 5048 KB Output is correct
5 Correct 24 ms 4944 KB Output is correct
6 Correct 27 ms 5096 KB Output is correct
7 Correct 24 ms 4948 KB Output is correct
8 Correct 25 ms 4956 KB Output is correct
9 Correct 24 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 25 ms 4956 KB Output is correct
3 Correct 25 ms 4956 KB Output is correct
4 Correct 26 ms 4956 KB Output is correct
5 Correct 26 ms 4948 KB Output is correct
6 Correct 25 ms 4896 KB Output is correct
7 Correct 26 ms 5200 KB Output is correct
8 Correct 27 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3420 KB Output is correct
3 Correct 3 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 24 ms 4568 KB Output is correct
7 Correct 28 ms 4956 KB Output is correct
8 Correct 24 ms 5048 KB Output is correct
9 Correct 24 ms 4944 KB Output is correct
10 Correct 2 ms 3416 KB Output is correct
11 Correct 25 ms 4956 KB Output is correct
12 Correct 25 ms 4956 KB Output is correct
13 Correct 26 ms 4956 KB Output is correct
14 Correct 3 ms 3416 KB Output is correct
15 Correct 24 ms 4956 KB Output is correct
16 Correct 24 ms 4948 KB Output is correct
17 Correct 24 ms 4860 KB Output is correct
18 Correct 27 ms 5096 KB Output is correct
19 Correct 24 ms 4948 KB Output is correct
20 Correct 25 ms 4956 KB Output is correct
21 Correct 24 ms 4956 KB Output is correct
22 Correct 26 ms 4948 KB Output is correct
23 Correct 25 ms 4896 KB Output is correct
24 Correct 26 ms 5200 KB Output is correct
25 Correct 27 ms 4692 KB Output is correct
26 Correct 25 ms 4948 KB Output is correct
27 Correct 25 ms 4956 KB Output is correct
28 Correct 25 ms 4956 KB Output is correct
29 Correct 32 ms 4952 KB Output is correct
30 Correct 24 ms 4948 KB Output is correct