Submission #891246

#TimeUsernameProblemLanguageResultExecution timeMemory
891246Tien_NoobAutomobil (COCI17_automobil)C++17
100 / 100
13 ms8536 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" using namespace std; const int mod = 1e9 + 7, N = 1e6; int r[N + 1], c[N + 1], k; long long n, m; vector<int> updr, updc; long long res; void read() { cin >> n >> m >> k; fill(r + 1, r + n + 1, 1); fill(c + 1, c + m + 1, 1); while(k--) { char t; int x, y; cin >> t >> x >> y; if (t == 'R') { r[x] = (1LL * r[x] * y) % mod; } if (t == 'S') { c[x] = (1LL * c[x] * y) % mod; } } } void solve() { for (int i = 1; i <= n; ++ i) { if (r[i] != 1) { res -= ((((i * m + (i - 1) * m + 1) * m / 2) % mod)) % mod; res %= mod; updr.push_back(i); } res += (((i * m + (i - 1) * m + 1) * m / 2) % mod) % mod; res %= mod; } for (int j = 1; j <= m; ++ j) { if (c[j] != 1) { updc.push_back(j); res -= ((((n - 1) * m + j + j) * n / 2) % mod) % mod; res %= mod; } } for (int i : updr) { res += ((((i * m + (i - 1) * m + 1) * m / 2) % mod) * r[i]) % mod; res %= mod; } for (int j : updc) { res += ((((n - 1) * m + j + j) * n / 2) % mod * c[j]) % mod; } for (int i : updr) { for (int j : updc) { long long cur = ((i - 1) * m + j) % mod; res += cur; res -= (cur * r[i]) % mod; res -= (cur * c[j]) % mod; res += ((cur * r[i]) % mod * c[j]) % mod; res %= mod; } } cout << (res + mod) % mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

Compilation message (stderr)

automobil.cpp: In function 'int main()':
automobil.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...