Submission #966600

#TimeUsernameProblemLanguageResultExecution timeMemory
966600kilkuwuStrange Device (APIO19_strange_device)C++17
10 / 100
846 ms524288 KiB
#include <bits/stdc++.h>

#define nl '\n'


signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;
  int64_t A, B;
  std::cin >> n >> A >> B;
  std::vector<int64_t> L(n), R(n);
  for (int i = 0; i < n; i++) {
    std::cin >> L[i] >> R[i];
  }

  auto calc = [&](int64_t t) -> std::pair<int64_t, int64_t> {
    auto y = t % B;
    auto x = (t + (t / B)) % A;
    return {x, y};
  };

  std::vector<std::pair<int64_t, int64_t>> shown;
  for (int i = 0; i < n; i++) {
    for (int64_t j = L[i]; j <= R[i]; j++) {
      shown.push_back(calc(j));
    }
  }

  std::sort(shown.begin(), shown.end());
  shown.erase(std::unique(shown.begin(), shown.end()), shown.end());
  std::cout << shown.size() << nl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...