QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692700 | #6703. Tokens on the Segments | Kdlyh# | WA | 78ms | 5124kb | C++20 | 2.3kb | 2024-10-31 14:55:23 | 2024-10-31 14:55:40 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <stack>
#ifdef LOCAL
template <class T, size_t size = std::tuple_size<T>::value> std::string to_debug(T, std::string s = "") requires(not std::ranges::range<T>);
std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); }
std::string to_debug(std::ranges::range auto x, std::string s = "") requires(not std::is_same_v<decltype(x), std::string>) {
for (auto xi : x) { s += ", " + to_debug(xi); }
return "[" + s.substr(s.empty() ? 0 : 2) + "]";
}
template <class T, size_t size> std::string to_debug(T x, std::string s) requires(not std::ranges::range<T>) {
[&]<size_t... I>(std::index_sequence<I...>) { ((s += ", " + to_debug(get<I>(x))), ...); }(std::make_index_sequence<size>());
return "(" + s.substr(s.empty() ? 0 : 2) + ")";
}
#define debug(...) std::cerr << __LINE__ << ": (" #__VA_ARGS__ ") = " << to_debug(std::tuple(__VA_ARGS__)) << "\n"
#else
#define debug(x...)
#endif
using i64 = long long;
#define int long long
void solve()
{
#define tests
int n; std::cin >> n;
std::vector<std::pair<int, int>> a(n); for (auto&[l, r] : a) {std::cin >> l >> r;}
std::sort(std::begin(a), std::end(a), [&](auto& i, auto& j) {
if (i.second == j.second) {
return i.first > j.first;
}
return i.second > j.second;
});
int lst{std::numeric_limits<int>::max()};
int ans{}; for (int i = 0; i < n; i++) {
auto&[l, r]{a.at(i)};
if (lst > r or (lst >= l and lst <= r)) {
ans += 1;
lst = std::min(lst - 1, r - 1);
}
}
std::cout << ans << "\n";
}
signed main()
{
std::cin.tie(nullptr)->sync_with_stdio(false);
int _{1};
#ifdef tests
std::cin >> _;
#endif
while(_--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 3 1 2 1 1 2 3 3 1 2 1 1 2 2
output:
3 2
result:
ok 2 number(s): "3 2"
Test #2:
score: -100
Wrong Answer
time: 78ms
memory: 5124kb
input:
10000 6 5 19 7 12 10 10 4 14 1 12 5 11 7 3 5 1 10 12 15 2 13 8 11 5 20 11 14 18 6 17 6 9 6 20 2 7 1 11 16 19 2 5 1 14 5 8 14 19 4 7 11 19 11 13 2 9 3 12 12 13 19 19 13 16 11 11 13 1 2 14 17 15 16 12 17 15 17 6 7 8 11 12 19 3 8 10 19 18 6 9 16 18 13 15 14 15 9 13 2 8 12 18 8 16 16 18 3 18 1 12 4 13 1...
output:
5 7 18 10 15 12 8 16 14 3 4 5 9 17 14 17 16 12 8 16 15 16 11 16 11 11 4 13 13 3 5 13 9 3 16 8 8 15 7 17 4 11 18 18 6 12 12 12 18 10 6 6 11 7 12 12 16 3 15 13 13 14 7 6 6 11 13 13 3 5 3 4 10 6 3 7 15 14 11 4 9 8 15 17 10 10 10 8 4 15 19 8 16 10 17 15 13 11 6 15 15 16 10 6 8 8 9 14 8 13 13 15 12 15 13...
result:
wrong answer 1st numbers differ - expected: '6', found: '5'