Submission #470910

#TimeUsernameProblemLanguageResultExecution timeMemory
470910mariowongAutomobil (COCI17_automobil)C++14
100 / 100
21 ms23756 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...