Submission #784458

# Submission time Handle Problem Language Result Execution time Memory
784458 2023-07-16T06:56:40 Z kebine Strange Device (APIO19_strange_device) C++17
0 / 100
5000 ms 2208 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int n, a, b;
vector<pair<int, int>> sg;

signed main() {
  int size;
  cin >> n >> a >> b;
  size = a*b;
  if ((b+1 % a) == 0) size = b;
  else if (size > 1e18) size = 1e18;
  cout << size << endl;

  int l, r;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    if (r - l + 1 >= size) {
      return 0;
    } else if (l%size > r%size) {
      sg.push_back({l%size, 1});
      sg.push_back({size-1, 2});
      sg.push_back({0, 1});
      sg.push_back({r%size, 2});
    } else {
      sg.push_back({l%size, 1});
      sg.push_back({r%size, 2});
    }
    sort(sg.begin(), sg.end());
  }

  int cnt = 0, l2;
  vector<pair<int, int>> ans;
  for (int i = 0; i < sg.size(); i++) {
    if (sg[i].second == 1) {
      if (cnt == 0) l2 = sg[i].first;
      cnt++;
    } else cnt--;

    if (cnt == 0) ans.push_back({l2, sg[i].first});
  }

  int res = 0;
  for (auto i: ans) {
    res += (i.second - i.first + 1);
  }
  cout << res << endl;

}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:36:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int i = 0; i < sg.size(); i++) {
      |                   ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1036 ms 1344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 19 ms 308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5099 ms 1644 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5099 ms 1644 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5099 ms 1644 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5061 ms 2208 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1036 ms 1344 KB Output isn't correct
3 Halted 0 ms 0 KB -