Submission #198593

#TimeUsernameProblemLanguageResultExecution timeMemory
198593ZwariowanyMarcinAutomobil (COCI17_automobil)C++14
100 / 100
21 ms8188 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;		

const int MOD = 1e9 + 7;

const int nax = 1e6 + 111;

int n, m, k;
char c;
int x, y;

int row[nax];
int col[nax];

int main() {
	scanf ("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= max(n, m); ++i)
		row[i] = col[i] = 1;
	for (int i = 1; i <= k; ++i) {
		scanf (" %c%d%d", &c, &x, &y);
		if (c == 'R')
			row[x] = 1LL * row[x] * y % MOD;
		else
			col[x] = 1LL * col[x] * y % MOD;
	}
	
	LL ans = 0;
	LL value = 0;
	LL sum = 0;
	
	for (int i = 1; i <= n; ++i) {
		sum = (sum + row[i]) % MOD;
		value = (value + 1LL * (1 + 1LL * (i - 1) * m) % MOD * row[i]) % MOD;
	}
	
	for (int i = 1; i <= m; ++i) {
		ans = (ans + value * col[i]) % MOD;
		value = (value + sum) % MOD;
	}
	printf ("%lld", ans);	
	
	return 0;
}

Compilation message (stderr)

automobil.cpp: In function 'int main()':
automobil.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d %d", &n, &m, &k);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
automobil.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf (" %c%d%d", &c, &x, &y);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...