| Task: | Toistot |
| Sender: | Yytsi |
| Submission time: | 2025-12-20 16:46:03 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| #4 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 2, 3, 4 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3, 4 | details |
| #4 | TIME LIMIT EXCEEDED | -- | 4 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 1, 2, 3, 4 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 4 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Token>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int i = 0; i < nums.size(); i++) {
| ~~^~~~~~~~~~~~~Code
#include <bits/stdc++.h>
using namespace std;
int q;
typedef long long ll;
struct Token {
ll x, a, b, qi;
Token(ll x) {
this->x = x;
this->a = 0;
this->b = 0;
this->qi = 0;
}
Token(ll x, ll a, ll b, ll qi) {
this->x = x;
this->a = a;
this->b = b;
this->qi = qi;
}
};
vector<Token> nums;
ll ans[1010];
ll to_number(const string& s) {
ll num = 0;
for (char c : s) {
ll digit = c - 48;
num *= 10LL;
num += digit;
}
return num;
}
unordered_set<string> added_already;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>q;
// 0-10**4-1
// multiplied to len=9 at most
for (int x = 1; x < 1000000; x++) {
string s = to_string(x);
string num = s;
while (true) {
num += s;
if (num.size() > 18) break;
if (added_already.count(num) == 0) {
added_already.insert(num);
nums.push_back(to_number(num));
} else break;
}
}
for (int i = 1; i <= q; i++) {
ll a, b; cin>>a>>b;
nums.push_back(Token(a, -1, 1, i));
nums.push_back(Token(b, 2, 1, i));
}
sort(nums.begin(), nums.end(), [&](Token& l, Token& r) {
if (l.x == r.x) return l.a < r.a;
else return l.x < r.x;
});
int cur_cnt = 0;
for (int i = 0; i < nums.size(); i++) {
Token c = nums[i];
if (c.a == -1) ans[c.qi] = cur_cnt;
if (c.a == 0) cur_cnt++;
if (c.a == 2) ans[c.qi] = cur_cnt - ans[c.qi];
}
for (int i = 1; i <= q; i++) cout<<ans[i]<<"\n";
}Test details
Test 1
Group: 1, 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 633 906 727 914 585 884 750 792 ... |
| correct output |
|---|
| 3 2 2 1 0 ... |
| user output |
|---|
| (empty) |
Test 2
Group: 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 647761 927345 744364 840268 598715 905836 767448 810881 ... |
| correct output |
|---|
| 303 105 333 48 95 ... |
| user output |
|---|
| (empty) |
Test 3
Group: 3, 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 663307073 949601845 762227828 860434499 613084013 927576203 785866095 830342436 ... |
| correct output |
|---|
| 286 98 314 44 89 ... |
| user output |
|---|
| (empty) |
Test 4
Group: 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 818435896335669158 98300938101... |
| correct output |
|---|
| 164737893 96015818 103821980 402263734 52636276 ... |
| user output |
|---|
| (empty) |
Test 5
Group: 1, 2, 3, 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 990 1 1 1 2 1 3 1 4 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Test 6
Group: 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 961 1 1000000000000000000 1 999999999999999999 1 999999999999999998 1 999999999999999997 ... |
| correct output |
|---|
| 1001000097 1001000097 1001000096 1001000096 1001000096 ... |
| user output |
|---|
| (empty) |
