Submission #519138

# Submission time Handle Problem Language Result Execution time Memory
519138 2022-01-25T18:08:19 Z cadmiumsky Strange Device (APIO19_strange_device) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int a,b,q;
  bool ok = 0;
  cin >> q >> a >> b;
  map<int,int> smen;
  int per = a * b / __gcd(b + 1, a); // formula magica care e motivata din.. niste calcule de clasa a 7a de algebra modulara O_o
  if(log10((double)a / (double)__gcd(b + 1, a)) + log10(b) >= 18)
    per = 1e18 + 1;
  for(int i = 0, cl, cr, l, r; i < q; i ++) {
    cin >> l >> r;
    cl = per * (l / per + 1);
    cr = per * (r / per);
    if(cl < cr) {
      ok = 1;
    }
    if(cl == cr) {
      l %= per;
      r %= per;
      smen[l]++;
      smen[0]++;
      smen[r + 1]--;
      cout << l <<  ' '<< per - 1 << '\n' << 0 << ' ' << r << '\n';
    }
    else {
      l %= per;
      r %= per;
      smen[l]++;
      smen[r + 1]--;
      cout << l << ' ' << r << '\n';
    }
  }
  if(ok) {
    cout << per << '\n';
    return 0;
  }
  smen[per];
  int total = 0, cnt = 0, last = -1;
  for(auto x : smen) {
    if(last != x.first && cnt > 0)
      total += x.first - last;
    if(x.first >= per)
      break;
    //cout << x.first <<  ' '<< x.second << '\n';
    cnt += x.second;
    last = x.first;
  }
  cout << total << '\n';
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -