Submission #470910

# Submission time Handle Problem Language Result Execution time Memory
470910 2021-09-06T07:43:59 Z mariowong Automobil (COCI17_automobil) C++14
100 / 100
21 ms 23756 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define x first
#define y second

const long long MOD = 1000000007;
const long long I2 = 500000004;

long long ans, top[1000055], d[1000055], rows[1000055];
int n, m, k; 

int main () {
	
	scanf("%d%d%d", &n, &m, &k);
	
	for (int i = 1; i <= m; i++) {
		top[i] = i;
		d[i] = m;
	}
	
	for (int i = 1; i <= n; i++)
		rows[i] = 1;
	
	while (k--) {
		char typ;
		int x, y;
		scanf("\n%c%d%d", &typ, &x, &y);
		
		if (typ == 'R') {
			rows[x] = rows[x] * y % MOD;
		} else
		if (typ == 'S') {
			top[x] = top[x] * y % MOD;
			d[x] = d[x] * y % MOD;
		}
	}
	
	long long topsum = 0, dsum = 0;
	
	for (int i = 1; i <= m; i++) {
		topsum += top[i];
		dsum += d[i];
	}
	
	topsum %= MOD;
	dsum %= MOD;
	
	for (int i = 1; i <= n; i++) 
		ans += rows[i] * ((long long)(i - 1) * dsum % MOD + topsum) % MOD; 
	
	printf("%lld\n", ans % MOD);
	
	return 0;
}

Compilation message

automobil.cpp: In function 'int main()':
automobil.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
automobil.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("\n%c%d%d", &typ, &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 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 204 KB Output is correct
11 Correct 3 ms 3660 KB Output is correct
12 Correct 11 ms 11684 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 11 ms 13132 KB Output is correct
15 Correct 12 ms 12964 KB Output is correct
16 Correct 21 ms 23752 KB Output is correct
17 Correct 21 ms 23628 KB Output is correct
18 Correct 18 ms 23756 KB Output is correct
19 Correct 21 ms 23636 KB Output is correct
20 Correct 18 ms 23744 KB Output is correct