Submission #720402

#TimeUsernameProblemLanguageResultExecution timeMemory
720402yellowtoadAutomobil (COCI17_automobil)C++17
100 / 100
19 ms15964 KiB
#include <iostream> #include <vector> using namespace std; const long long mod = 1000000007; long long int n, m, k, x, y, sum = 0, b[2][1000010]; char ch; vector<pair<long long,long long>> a[2]; // R = 0; S = 1; int main() { cin >> n >> m >> k; for (int i = 1; i <= k; i++) { cin >> ch >> x >> y; for (int j = 0; j < a[ch%2].size(); j++) { if (a[ch%2][j].first == x) { a[ch%2][j].second *= y; a[ch%2][j].second %= mod; goto skip; } } a[ch%2].push_back({x,y}); skip:; } for (int i = 1; i <= n; i++) b[0][i] = ((m*(i-1))+1+(m*(i-1))+m)*m/2; for (int i = 1; i <= m; i++) b[1][i] = (i+((n-1)*m)+i)*n/2; for (int i = 1; i <= n; i++) { sum += b[0][i]; sum %= mod; } for (int i = 0; i < a[0].size(); i++) { sum += ((b[0][a[0][i].first]%mod)*((a[0][i].second-1)%mod)+mod)%mod; sum = (sum+mod)%mod; } for (int i = 0; i < a[1].size(); i++) { sum += ((b[1][a[1][i].first]%mod)*((a[1][i].second-1)%mod)+mod)%mod; sum = (sum+mod)%mod; } for (int i = 0; i < a[0].size(); i++) { for (int j = 0; j < a[1].size(); j++) { sum = (sum-((((a[0][i].first-1)*m+a[1][j].first)%mod)*(a[0][i].second%mod))%mod-((((a[0][i].first-1)*m+a[1][j].first)%mod)*(a[1][j].second%mod))%mod+((((a[0][i].first-1)*m+a[1][j].first)%mod)*((((a[1][j].second%mod)*(a[0][i].second%mod))+1)%mod))%mod)%mod; sum = (sum+mod)%mod; } } cout << (sum+mod)%mod << endl; }

Compilation message (stderr)

automobil.cpp: In function 'int main()':
automobil.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int j = 0; j < a[ch%2].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~
automobil.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i = 0; i < a[0].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
automobil.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i = 0; i < a[1].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
automobil.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for (int i = 0; i < a[0].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
automobil.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int j = 0; j < a[1].size(); j++) {
      |                   ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...