Submission #741461

# Submission time Handle Problem Language Result Execution time Memory
741461 2023-05-14T06:22:02 Z abczz Strange Device (APIO19_strange_device) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <array>
#define ll long long

using namespace std;

ll n, a, b;
bool B;
vector <ll> V;
__int128 z, x, y, l, r, f;
vector<array<__int128, 2>> A;
int main() {
  cin >> n >> a >> b;
  x = a;
  y = b;
  z = x*y;
  for (int i=0; i<n; ++i) {
    cin >> a >> b;
    x = a, y = b;
    l = y-x;
    x %= z;
    if (x+l >= z) {
      l -= z;
      l = min(l, z-1);
      A.push_back({x, z-1});
      A.push_back({0, l});
    }
    else A.push_back({x, x+l});
  }
  sort(A.begin(), A.end());
  l = r = -1e9;
  ++l;
  for (auto [u, v] : A) {
    if (r+1 < u) {
      f += r-l+1;
      l = u, r = v;
    }
    else r = max(r, v);
  }
  f += (r-l)+1;
  while (f) {
    V.push_back(f%10);
    f /= 10;
  }
  reverse(V.begin(), V.end());
  for (auto u : V) {
    cout << u;
  }
  cout << '\n';
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:31:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   31 |   sort(A.begin(), A.end());
      |   ^~~~
      |   qsort
strange_device.cpp:34:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |   for (auto [u, v] : A) {
      |             ^
strange_device.cpp:46:3: error: 'reverse' was not declared in this scope
   46 |   reverse(V.begin(), V.end());
      |   ^~~~~~~