Submission #471727

# Submission time Handle Problem Language Result Execution time Memory
471727 2021-09-10T14:40:52 Z rainboy Automobil (COCI17_automobil) C
100 / 100
18 ms 8120 KB
#include <stdio.h>

#define N	1000000
#define M	1000000
#define MD	1000000007

int main() {
	static int aa[N], bb[M];
	int n, m, k, i, j, a, b, c, d;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0; i < n; i++)
		aa[i] = 1;
	for (j = 0; j < m; j++)
		bb[j] = 1;
	while (k--) {
		static char s[2];
		int x;

		scanf("%s", s);
		if (s[0] == 'R') {
			scanf("%d%d", &i, &x), i--;
			aa[i] = (long long) aa[i] * x % MD;
		} else {
			scanf("%d%d", &j, &x), j--;
			bb[j] = (long long) bb[j] * x % MD;
		}
	}
	/* (i m + j + 1) aa[i] bb[j] = (i aa[i] bb[j]) m + (j bb[j] aa[i]) + aa[i] bb[j] */
	a = 0, c = 0;
	for (i = 0; i < n; i++)
		a = (a + aa[i]) % MD, c = (c + (long long) aa[i] * i) % MD;
	b = 0, d = 0;
	for (j = 0; j < m; j++)
		b = (b + bb[j]) % MD, d = (d + (long long) bb[j] * j) % MD;
	printf("%lld\n", ((long long) b * c % MD * m % MD + (long long) a * d % MD + (long long) a * b % MD) % MD);
	return 0;
}

Compilation message

automobil.c: In function 'main':
automobil.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
automobil.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%s", s);
      |   ^~~~~~~~~~~~~~
automobil.c:22:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |    scanf("%d%d", &i, &x), i--;
      |    ^~~~~~~~~~~~~~~~~~~~~
automobil.c:25:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    scanf("%d%d", &j, &x), j--;
      |    ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 3 ms 1484 KB Output is correct
12 Correct 10 ms 4492 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 9 ms 5068 KB Output is correct
15 Correct 16 ms 4656 KB Output is correct
16 Correct 16 ms 8116 KB Output is correct
17 Correct 16 ms 8116 KB Output is correct
18 Correct 16 ms 8120 KB Output is correct
19 Correct 15 ms 8100 KB Output is correct
20 Correct 18 ms 8012 KB Output is correct