| Task: | LibBot |
| Sender: | aalto26bw_009 |
| Submission time: | 2026-09-09 17:46:53 +0300 |
| Language: | C++ (C++23) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.01 s | details |
| #4 | ACCEPTED | 0.01 s | details |
| #5 | ACCEPTED | 0.01 s | details |
| #6 | ACCEPTED | 0.01 s | details |
| #7 | ACCEPTED | 0.01 s | details |
| #8 | ACCEPTED | 0.01 s | details |
| #9 | ACCEPTED | 0.01 s | details |
| #10 | ACCEPTED | 0.01 s | details |
| #11 | ACCEPTED | 0.01 s | details |
| #12 | ACCEPTED | 0.01 s | details |
| #13 | ACCEPTED | 0.01 s | details |
| #14 | ACCEPTED | 0.01 s | details |
| #15 | ACCEPTED | 0.01 s | details |
| #16 | ACCEPTED | 0.01 s | details |
| #17 | ACCEPTED | 0.01 s | details |
| #18 | ACCEPTED | 0.01 s | details |
| #19 | ACCEPTED | 0.01 s | details |
| #20 | ACCEPTED | 0.01 s | details |
| #21 | ACCEPTED | 0.01 s | details |
| #22 | ACCEPTED | 0.01 s | details |
| #23 | ACCEPTED | 0.01 s | details |
| #24 | ACCEPTED | 0.01 s | details |
| #25 | ACCEPTED | 0.01 s | details |
| #26 | ACCEPTED | 0.01 s | details |
| #27 | ACCEPTED | 0.01 s | details |
| #28 | ACCEPTED | 0.01 s | details |
| #29 | ACCEPTED | 0.01 s | details |
| #30 | ACCEPTED | 0.01 s | details |
| #31 | ACCEPTED | 0.01 s | details |
| #32 | ACCEPTED | 0.01 s | details |
| #33 | ACCEPTED | 0.01 s | details |
| #34 | ACCEPTED | 0.01 s | details |
| #35 | ACCEPTED | 0.01 s | details |
| #36 | ACCEPTED | 0.01 s | details |
| #37 | ACCEPTED | 0.01 s | details |
| #38 | ACCEPTED | 0.01 s | details |
| #39 | ACCEPTED | 0.01 s | details |
| #40 | ACCEPTED | 0.01 s | details |
| #41 | ACCEPTED | 0.01 s | details |
Code
// #ifdef ONLINE_JUDGE
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #endif
#include "bits/stdc++.h"
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i, a, b) for(__typeof(b) i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for(__typeof(a) i = a, _b = b; i >= _b; --i)
#define ALL(a) (a).begin(), (a).end()
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define dq deque<int>
#define nend '\n'
using namespace std;
const ll inf = 1e18;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int MOD = 1e9 + 7;
const ll hashi = 2e9 + 11;
const int N=1e5+3;
inline ll add(ll a, ll b) { return (a + b) % MOD; }
inline ll sub(ll a, ll b) { return ((a - b) % MOD + MOD) % MOD; }
inline ll mul(ll a, ll b) { return (a * b) % MOD; }
inline ll binpow(ll a, ll b) {
ll res = 1;
a %= MOD;
while (b > 0) {
if (b & 1) res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
inline ll modInverse(ll n) {
return binpow(n, MOD - 2);
}
inline ll modDivide(ll a, ll b) {
return (a % MOD * modInverse(b)) % MOD;
}
ll extended_gcd(ll a, ll b, ll& x, ll& y) {
if (b == 0) {
x = 1; y = 0;
return a;
}
ll x1, y1;
ll d = extended_gcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
void init_code() {
fast;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
}
int n;
string target;
string cache_title[N];
bool vis[N];
string query(int x) {
if (vis[x]) return cache_title[x];
int temp = x;
int e = temp % n + 1; temp /= n;
int d = temp % n + 1; temp /= n;
int c = temp % n + 1; temp /= n;
int b = temp % n + 1; temp /= n;
int a = temp % n + 1;
cout << "FETCH " << a << "." << b << "." << c << "." << d << "." << e << endl;
string status, res;
cin >> status >> res;
vis[x] = true;
return cache_title[x] = res;
}
void solve() {
string type;
if (!(cin >> type >> n)) return;
cin >> type >> target;
int total_books = 1;
FOR(i, 1, 5) total_books *= n;
int l = 0, r = total_books - 1;
int first_idx = total_books;
while (l <= r) {
int mid = l + (r - l) / 2;
if (query(mid) >= target) {
first_idx = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
l = 0; r = total_books - 1;
int last_idx = total_books;
while (l <= r) {
int mid = l + (r - l) / 2;
if (query(mid) > target) {
last_idx = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
int ans = last_idx - first_idx;
cout << "GOT " << ans << endl;
}
int main() {
init_code();
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 2 9 kdg dl 6 kdg 3 kdgwl 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 2 COUNT kdg FETCH 1.2.2.2.2 FOUND kdgyi FETCH 1.1.2.2.2 ... |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 3 15 irwkfl c 26 d 27 e 11 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 3 COUNT irwkfl FETCH 2.2.2.2.2 FOUND fuuics FETCH 3.1.3.1.3 ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 4 34 gcnmkobrd bcytu 60 bheb 64 bhebp 26 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 4 COUNT gcnmkobrd FETCH 2.4.4.4.4 FOUND h FETCH 1.4.4.4.4 ... |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 5 52 faoluuicsn a 1 cufqs 30 d 44 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 5 COUNT faoluuicsn FETCH 3.3.3.3.3 FOUND o FETCH 2.2.2.2.1 ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 6 75 okokxlluuicsnw a 1 b 51 bxcufq 145 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 6 COUNT okokxlluuicsnw FETCH 3.6.6.6.6 FOUND okhkxlluurcsnwcvbheipdry... |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 7 105 jibgewnvmqnpbxvirxmgf a 1 aqykhme 32 atusxwa 119 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT jibgewnvmqnpbxvirxmgf FETCH 4.4.4.4.4 FOUND n FETCH 2.6.2.6.2 ... |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 8 124 djnofmgdbfj afpc 66 apj 204 apjgsu 105 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT djnofmgdbfj FETCH 4.8.8.8.8 FOUND mdaecaalyy FETCH 2.8.8.8.8 ... |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 9 166 qonvyqgibutxey a 94 act 683 afngrwb 20 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT qonvyqgibutxey FETCH 5.5.5.5.5 FOUND ox FETCH 7.7.7.7.7 ... |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 10 211 zuek axof 303 axofdxjyeevjxifd 397 axofvxnleg 539 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 10 COUNT zuek FETCH 5.10.10.10.10 FOUND moh FETCH 8.5.10.10.10 ... |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 10 216 hskapswvzfrbijqwgotkothu aayuulyq 436 aayuulyqcs 205 aayuulyqcsgjqffbfix 530 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 10 COUNT hskapswvzfrbijqwgotkothu FETCH 5.10.10.10.10 FOUND jogii FETCH 3.5.10.10.10 ... |
Test 11
Verdict: ACCEPTED
| input |
|---|
| 9 158 ylhjecnhgyboje a 691 acd 241 apkcczfzzxrpvlk 88 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT ylhjecnhgyboje FETCH 5.5.5.5.5 FOUND kxtjsyjajvusmj FETCH 7.7.7.7.7 ... |
Test 12
Verdict: ACCEPTED
| input |
|---|
| 8 133 ewcm aavhwtselm 486 aavrwtsejm 170 aayuuly 62 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT ewcm FETCH 4.8.8.8.8 FOUND kjogxxxfyzbvtqxnmiok FETCH 2.8.8.8.8 ... |
Test 13
Verdict: ACCEPTED
| input |
|---|
| 7 98 jkpxbvb awb 326 comccswxez 114 cw 42 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT jkpxbvb FETCH 4.4.4.4.4 FOUND lqsc FETCH 2.6.2.6.2 ... |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 6 70 eaymki alkio 119 alkioruv 72 alkioruvyivod 26 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 6 COUNT eaymki FETCH 3.6.6.6.6 FOUND lzftwy FETCH 2.3.6.6.6 ... |
Test 15
Verdict: ACCEPTED
| input |
|---|
| 4 28 unje biybsjet 60 biybsjetnn 27 bx 45 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 4 COUNT unje FETCH 2.4.4.4.4 FOUND npghbml FETCH 3.4.4.4.4 ... |
Test 16
Verdict: ACCEPTED
| input |
|---|
| 9 159 ckfhsouqxvv a 373 aahay 152 asvvihxxokcevotlncilqbuvhmdkmh... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT ckfhsouqxvv FETCH 5.5.5.5.5 FOUND lk FETCH 3.3.3.3.2 ... |
Test 17
Verdict: ACCEPTED
| input |
|---|
| 8 117 h aaha 262 anmuhfjbetlfzdbns 107 awhfbhdbjbuexgbwl 226 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT h FETCH 4.8.8.8.8 FOUND ns FETCH 2.8.8.8.8 ... |
Test 18
Verdict: ACCEPTED
| input |
|---|
| 7 106 m aezpq 42 aokpn 7 aqfkfe 86 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT m FETCH 4.4.4.4.4 FOUND mljjsrvri FETCH 2.6.2.6.2 ... |
Test 19
Verdict: ACCEPTED
| input |
|---|
| 7 101 kvtwj appvlr 240 bguzpylrzkwon 78 bofd 2 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT kvtwj FETCH 4.4.4.4.4 FOUND oekjahqd FETCH 2.6.2.6.2 ... |
Test 20
Verdict: ACCEPTED
| input |
|---|
| 2 9 fu dl 6 kdg 3 kdgwl 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 2 COUNT fu FETCH 1.2.2.2.2 FOUND kdgyi FETCH 1.1.2.2.2 ... |
Test 21
Verdict: ACCEPTED
| input |
|---|
| 3 15 uvk c 26 d 27 e 11 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 3 COUNT uvk FETCH 2.2.2.2.2 FOUND fuuics FETCH 3.1.3.1.3 ... |
Test 22
Verdict: ACCEPTED
| input |
|---|
| 4 34 jgtx bcytu 60 bheb 64 bhebp 26 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 4 COUNT jgtx FETCH 2.4.4.4.4 FOUND h FETCH 3.4.4.4.4 ... |
Test 23
Verdict: ACCEPTED
| input |
|---|
| 5 52 ghmfq a 1 cufqs 30 d 44 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 5 COUNT ghmfq FETCH 3.3.3.3.3 FOUND o FETCH 2.2.2.2.1 ... |
Test 24
Verdict: ACCEPTED
| input |
|---|
| 6 75 ojuphd a 1 b 51 bxcufq 145 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 6 COUNT ojuphd FETCH 3.6.6.6.6 FOUND okhkxlluurcsnwcvbheipdry... |
Test 25
Verdict: ACCEPTED
| input |
|---|
| 7 105 kzzqfzz a 1 aqykhme 32 atusxwa 119 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT kzzqfzz FETCH 4.4.4.4.4 FOUND n FETCH 2.6.2.6.2 ... |
Test 26
Verdict: ACCEPTED
| input |
|---|
| 8 124 emdxvwdw afpc 66 apj 204 apjgsu 105 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT emdxvwdw FETCH 4.8.8.8.8 FOUND mdaecaalyy FETCH 2.8.8.8.8 ... |
Test 27
Verdict: ACCEPTED
| input |
|---|
| 9 166 pkhsbasuj a 94 act 683 afngrwb 20 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT pkhsbasuj FETCH 5.5.5.5.5 FOUND ox FETCH 7.7.7.7.7 ... |
Test 28
Verdict: ACCEPTED
| input |
|---|
| 10 211 zypqadmqoo axof 303 axofdxjyeevjxifd 397 axofvxnleg 539 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 10 COUNT zypqadmqoo FETCH 5.10.10.10.10 FOUND moh FETCH 8.5.10.10.10 ... |
Test 29
Verdict: ACCEPTED
| input |
|---|
| 10 216 jhagispreh aayuulyq 436 aayuulyqcs 205 aayuulyqcsgjqffbfix 530 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 10 COUNT jhagispreh FETCH 5.10.10.10.10 FOUND jogii FETCH 3.5.10.10.10 ... |
Test 30
Verdict: ACCEPTED
| input |
|---|
| 9 158 zfkmqpzht a 691 acd 241 apkcczfzzxrpvlk 88 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT zfkmqpzht FETCH 5.5.5.5.5 FOUND kxtjsyjajvusmj FETCH 7.7.7.7.7 ... |
Test 31
Verdict: ACCEPTED
| input |
|---|
| 8 133 dogiavnu aavhwtselm 486 aavrwtsejm 170 aayuuly 62 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT dogiavnu FETCH 4.8.8.8.8 FOUND kjogxxxfyzbvtqxnmiok FETCH 2.8.8.8.8 ... |
Test 32
Verdict: ACCEPTED
| input |
|---|
| 7 98 kihqiff awb 326 comccswxez 114 cw 42 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT kihqiff FETCH 4.4.4.4.4 FOUND lqsc FETCH 2.6.2.6.2 ... |
Test 33
Verdict: ACCEPTED
| input |
|---|
| 6 70 eszubi alkio 119 alkioruv 72 alkioruvyivod 26 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 6 COUNT eszubi FETCH 3.6.6.6.6 FOUND lzftwy FETCH 2.3.6.6.6 ... |
Test 34
Verdict: ACCEPTED
| input |
|---|
| 4 28 vyta biybsjet 60 biybsjetnn 27 bx 45 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 4 COUNT vyta FETCH 2.4.4.4.4 FOUND npghbml FETCH 3.4.4.4.4 ... |
Test 35
Verdict: ACCEPTED
| input |
|---|
| 9 159 ctohjykey a 373 aahay 152 asvvihxxokcevotlncilqbuvhmdkmh... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 9 COUNT ctohjykey FETCH 5.5.5.5.5 FOUND lk FETCH 3.3.3.3.2 ... |
Test 36
Verdict: ACCEPTED
| input |
|---|
| 8 117 igjxpndn aaha 262 anmuhfjbetlfzdbns 107 awhfbhdbjbuexgbwl 226 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 8 COUNT igjxpndn FETCH 4.8.8.8.8 FOUND ns FETCH 2.8.8.8.8 ... |
Test 37
Verdict: ACCEPTED
| input |
|---|
| 7 106 lslhnht aezpq 42 aokpn 7 aqfkfe 86 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT lslhnht FETCH 4.4.4.4.4 FOUND mljjsrvri FETCH 2.6.2.6.2 ... |
Test 38
Verdict: ACCEPTED
| input |
|---|
| 7 101 hxliesh appvlr 240 bguzpylrzkwon 78 bofd 2 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 7 COUNT hxliesh FETCH 4.4.4.4.4 FOUND oekjahqd FETCH 2.6.2.6.2 ... |
Test 39
Verdict: ACCEPTED
| input |
|---|
| 2 1 fu dl 32 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 2 COUNT fu FETCH 1.2.2.2.2 FOUND dl FETCH 2.1.2.2.2 ... |
Test 40
Verdict: ACCEPTED
| input |
|---|
| 3 1 fuuicsxvc fuuicsxvc 243 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 3 COUNT fuuicsxvc FETCH 2.2.2.2.2 FOUND fuuicsxvc FETCH 1.3.1.3.1 ... |
Test 41
Verdict: ACCEPTED
| input |
|---|
| 4 1 bcytu bcytu 1024 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| SIZE 4 COUNT bcytu FETCH 2.4.4.4.4 FOUND bcytu FETCH 1.4.4.4.4 ... |
