QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#815370#9879. ReTravelucup-team987#WA 0ms3612kbC++232.2kb2024-12-15 13:34:252024-12-15 13:34:30

Judging History

This is the latest submission verdict.

  • [2024-12-15 13:34:30]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3612kb
  • [2024-12-15 13:34:25]
  • Submitted

answer

#if __INCLUDE_LEVEL__ == 0

#include __BASE_FILE__

void Solve() {
  int n;
  IN(n);
  vector<int> x(n), y(n);
  for (int i : Rep(0, n)) {
    IN(x[i], y[i]);
  }

  int64_t ans = 0;
  vector<pair<int, int>> v{{0, 0}};
  for (int i : Rep(0, n)) {
    int last_x = INF;
    int last_y = INF;
    while (!(v.back().first <= x[i] && v.back().second <= y[i])) {
      tie(last_x, last_y) = v.back();
      v.pop_back();
    }
    if (last_x == INF) {
      assert(last_y == INF);
      if (v.back() != pair(x[i], y[i])) {
        ans += x[i] - v.back().first;
        ans += y[i] - v.back().second;
        v.emplace_back(x[i], y[i]);
      }
    } else {
      int x2 = min(x[i], last_x);
      int y2 = min(y[i], last_y);
      if (v.back() != pair(x2, y2)) {
        v.emplace_back(x2, y2);
      }
      if (v.back() != pair(x[i], y[i])) {
        ans += x[i] - x2;
        ans += y[i] - y2;
        v.emplace_back(x[i], y[i]);
      }
    }
  }
  OUT(ans);
}

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

  Solve();
}

#elif __INCLUDE_LEVEL__ == 1

#include <bits/stdc++.h>

template <class T> concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;

namespace std {

istream& operator>>(istream& is, Range auto&& r) {
  for (auto&& e : r) is >> e;
  return is;
}
istream& operator>>(istream& is, Tuple auto&& t) {
  apply([&](auto&... xs) { (is >> ... >> xs); }, t);
  return is;
}

ostream& operator<<(ostream& os, Range auto&& r) {
  auto sep = "";
  for (auto&& e : r) os << exchange(sep, " ") << e;
  return os;
}
ostream& operator<<(ostream& os, Tuple auto&& t) {
  auto sep = "";
  apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);
  return os;
}

}  // namespace std

using namespace std;

#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)
#define INF (INT_MAX / 2)
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')

#endif  // __INCLUDE_LEVEL__ == 1

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

2
3 3
1 2

output:

6

result:

ok "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3
2 2
3 3
1 3

output:

7

result:

ok "7"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

500
906691059 413653999
813847339 955892128
451585301 43469773
278009742 548977048
521760889 434794718
985946604 841597326
891047768 325679554
511742081 384452587
626401695 957413342
975078788 234551094
541903389 149544006
302621084 150050891
811538590 101823753
663968655 858351976
268979133 9768326...

output:

233625568926

result:

wrong answer 1st words differ - expected: '202616034783', found: '233625568926'