CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:LibBot
Sender:aalto2024b_008
Submission time:2024-09-11 17:31:24 +0300
Language:C++11
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.02 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails
#9ACCEPTED0.02 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.02 sdetails
#12ACCEPTED0.02 sdetails
#13ACCEPTED0.02 sdetails
#14ACCEPTED0.01 sdetails
#15ACCEPTED0.01 sdetails
#16ACCEPTED0.01 sdetails
#17ACCEPTED0.01 sdetails
#18ACCEPTED0.02 sdetails
#19ACCEPTED0.01 sdetails
#20ACCEPTED0.01 sdetails
#21ACCEPTED0.01 sdetails
#22ACCEPTED0.02 sdetails
#23ACCEPTED0.02 sdetails
#24ACCEPTED0.01 sdetails
#25ACCEPTED0.01 sdetails
#26ACCEPTED0.01 sdetails
#27ACCEPTED0.02 sdetails
#28ACCEPTED0.01 sdetails
#29ACCEPTED0.02 sdetails
#30ACCEPTED0.02 sdetails
#31ACCEPTED0.01 sdetails
#32ACCEPTED0.02 sdetails
#33ACCEPTED0.02 sdetails
#34ACCEPTED0.02 sdetails
#35ACCEPTED0.02 sdetails
#36ACCEPTED0.02 sdetails
#37ACCEPTED0.01 sdetails
#38ACCEPTED0.02 sdetails
#39ACCEPTED0.02 sdetails
#40ACCEPTED0.02 sdetails
#41ACCEPTED0.01 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

int N, N2, N3, N4;
string NAME;

typedef struct {
    int a, b, c, d, e;
} POS;

map<int, string> MAP;

int code_to_index(int a, int b, int c, int d, int e) {
    return (e-1) + (d-1)*N + (c-1)*N2 + (b-1)*N3 + (a-1)*N4;
}

void index_to_code(int index, int &a, int &b, int &c, int &d, int &e) {
    a = index / N4;
    b = (index - a*N4) / N3;
    c = (index - a*N4 - b*N3) / N2;
    d = (index - a*N4 - b*N3 - c*N2) / N;
    e = (index - a*N4 - b*N3 - c*N2 - d*N);
    a++, b++, c++, d++, e++;
}

int main() {

    string sink;

    cin >> sink >> N;
    cin >> sink >> NAME;

    N2 = N*N;
    N3 = N*N2;
    N4 = N*N3;

    int lower_left = 0;
    int lower_right = N*N4;

    while (lower_left < lower_right) {
        int middle = (lower_left + lower_right) / 2;

        int a, b, c, d, e;
        index_to_code(middle, a, b, c, d, e);

        string found;

        if (MAP.count(middle)) {
            found = MAP[middle];
        } else {
            cout << "FETCH " << a << "." << b << "." << c << "." << d << "." << e << endl;
            cin >> sink >> found;
            MAP[middle] = found;
        }

        if (found < NAME) {
            lower_left = middle+1;
        } else {
            lower_right = middle;
        }

    }

    int X = lower_left;

    int upper_left = 0;
    int upper_right = N*N4;

    while (upper_left < upper_right) {
        int middle = (upper_left + upper_right) / 2;

        int a, b, c, d, e;
        index_to_code(middle, a, b, c, d, e);

        string found;

        if (MAP.count(middle)) {
            found = MAP[middle];
        } else {
            cout << "FETCH " << a << "." << b << "." << c << "." << d << "." << e << endl;
            cin >> sink >> found;
            MAP[middle] = found;
        }

        if (found <= NAME) {
            upper_left = middle+1;
        } else {
            upper_right = middle;
        }

    }

    int Y = upper_left;

    cout << "GOT " << Y-X << endl;

    return 0;

}

/*
> SIZE 10
> COUNT abc
< FETCH 1.2.3.4.5
> FOUND abb
< FETCH 1.2.3.4.6
> FOUND abc
< FETCH 1.2.3.5.6
> FOUND abc
< FETCH 1.2.3.5.7
> FOUND abd
< GOT 11
*/

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 2.1.1.1.1
FOUND kdgyi
FETCH 1.2.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 3

Verdict: ACCEPTED

input
4 34
gcnmkobrd
bcytu 60
bheb 64
bhebp 26
...

correct output
(empty)

user output
SIZE 4
COUNT gcnmkobrd
FETCH 3.1.1.1.1
FOUND h
FETCH 2.1.1.1.1
...

Error:
1 1 1 0

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.2
...

Error:
1 1 1 0

Test 5

Verdict: ACCEPTED

input
6 75
okokxlluuicsnw
a 1
b 51
bxcufq 145
...

correct output
(empty)

user output
SIZE 6
COUNT okokxlluuicsnw
FETCH 4.1.1.1.1
FOUND okhkxlluurcsnwcvbheipdry...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 7

Verdict: ACCEPTED

input
8 124
djnofmgdbfj
afpc 66
apj 204
apjgsu 105
...

correct output
(empty)

user output
SIZE 8
COUNT djnofmgdbfj
FETCH 5.1.1.1.1
FOUND mdaecaalyy
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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.8
...

Error:
1 1 1 0

Test 9

Verdict: ACCEPTED

input
10 211
zuek
axof 303
axofdxjyeevjxifd 397
axofvxnleg 539
...

correct output
(empty)

user output
SIZE 10
COUNT zuek
FETCH 6.1.1.1.1
FOUND moh
FETCH 8.6.1.1.1
...

Error:
1 1 1 0

Test 10

Verdict: ACCEPTED

input
10 216
hskapswvzfrbijqwgotkothu
aayuulyq 436
aayuulyqcs 205
aayuulyqcsgjqffbfix 530
...

correct output
(empty)

user output
SIZE 10
COUNT hskapswvzfrbijqwgotkothu
FETCH 6.1.1.1.1
FOUND jogii
FETCH 3.6.1.1.1
...

Error:
1 1 1 0

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.8
...

Error:
1 1 1 0

Test 12

Verdict: ACCEPTED

input
8 133
ewcm
aavhwtselm 486
aavrwtsejm 170
aayuuly 62
...

correct output
(empty)

user output
SIZE 8
COUNT ewcm
FETCH 5.1.1.1.1
FOUND kjogxxxfyzbvtqxnmiok
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 14

Verdict: ACCEPTED

input
6 70
eaymki
alkio 119
alkioruv 72
alkioruvyivod 26
...

correct output
(empty)

user output
SIZE 6
COUNT eaymki
FETCH 4.1.1.1.1
FOUND lzftwy
FETCH 2.4.1.1.1
...

Error:
1 1 1 0

Test 15

Verdict: ACCEPTED

input
4 28
unje
biybsjet 60
biybsjetnn 27
bx 45
...

correct output
(empty)

user output
SIZE 4
COUNT unje
FETCH 3.1.1.1.1
FOUND npghbml
FETCH 4.1.1.1.1
...

Error:
1 1 1 0

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.3
...

Error:
1 1 1 0

Test 17

Verdict: ACCEPTED

input
8 117
h
aaha 262
anmuhfjbetlfzdbns 107
awhfbhdbjbuexgbwl 226
...

correct output
(empty)

user output
SIZE 8
COUNT h
FETCH 5.1.1.1.1
FOUND ns
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 20

Verdict: ACCEPTED

input
2 9
fu
dl 6
kdg 3
kdgwl 1
...

correct output
(empty)

user output
SIZE 2
COUNT fu
FETCH 2.1.1.1.1
FOUND kdgyi
FETCH 1.2.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 22

Verdict: ACCEPTED

input
4 34
jgtx
bcytu 60
bheb 64
bhebp 26
...

correct output
(empty)

user output
SIZE 4
COUNT jgtx
FETCH 3.1.1.1.1
FOUND h
FETCH 4.1.1.1.1
...

Error:
1 1 1 0

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.2
...

Error:
1 1 1 0

Test 24

Verdict: ACCEPTED

input
6 75
ojuphd
a 1
b 51
bxcufq 145
...

correct output
(empty)

user output
SIZE 6
COUNT ojuphd
FETCH 4.1.1.1.1
FOUND okhkxlluurcsnwcvbheipdry...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 26

Verdict: ACCEPTED

input
8 124
emdxvwdw
afpc 66
apj 204
apjgsu 105
...

correct output
(empty)

user output
SIZE 8
COUNT emdxvwdw
FETCH 5.1.1.1.1
FOUND mdaecaalyy
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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.8
...

Error:
1 1 1 0

Test 28

Verdict: ACCEPTED

input
10 211
zypqadmqoo
axof 303
axofdxjyeevjxifd 397
axofvxnleg 539
...

correct output
(empty)

user output
SIZE 10
COUNT zypqadmqoo
FETCH 6.1.1.1.1
FOUND moh
FETCH 8.6.1.1.1
...

Error:
1 1 1 0

Test 29

Verdict: ACCEPTED

input
10 216
jhagispreh
aayuulyq 436
aayuulyqcs 205
aayuulyqcsgjqffbfix 530
...

correct output
(empty)

user output
SIZE 10
COUNT jhagispreh
FETCH 6.1.1.1.1
FOUND jogii
FETCH 3.6.1.1.1
...

Error:
1 1 1 0

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.8
...

Error:
1 1 1 0

Test 31

Verdict: ACCEPTED

input
8 133
dogiavnu
aavhwtselm 486
aavrwtsejm 170
aayuuly 62
...

correct output
(empty)

user output
SIZE 8
COUNT dogiavnu
FETCH 5.1.1.1.1
FOUND kjogxxxfyzbvtqxnmiok
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 33

Verdict: ACCEPTED

input
6 70
eszubi
alkio 119
alkioruv 72
alkioruvyivod 26
...

correct output
(empty)

user output
SIZE 6
COUNT eszubi
FETCH 4.1.1.1.1
FOUND lzftwy
FETCH 2.4.1.1.1
...

Error:
1 1 1 0

Test 34

Verdict: ACCEPTED

input
4 28
vyta
biybsjet 60
biybsjetnn 27
bx 45
...

correct output
(empty)

user output
SIZE 4
COUNT vyta
FETCH 3.1.1.1.1
FOUND npghbml
FETCH 4.1.1.1.1
...

Error:
1 1 1 0

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.3
...

Error:
1 1 1 0

Test 36

Verdict: ACCEPTED

input
8 117
igjxpndn
aaha 262
anmuhfjbetlfzdbns 107
awhfbhdbjbuexgbwl 226
...

correct output
(empty)

user output
SIZE 8
COUNT igjxpndn
FETCH 5.1.1.1.1
FOUND ns
FETCH 3.1.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 39

Verdict: ACCEPTED

input
2 1
fu
dl 32

correct output
(empty)

user output
SIZE 2
COUNT fu
FETCH 2.1.1.1.1
FOUND dl
FETCH 2.2.1.1.1
...

Error:
1 1 1 0

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
...

Error:
1 1 1 0

Test 41

Verdict: ACCEPTED

input
4 1
bcytu
bcytu 1024

correct output
(empty)

user output
SIZE 4
COUNT bcytu
FETCH 3.1.1.1.1
FOUND bcytu
FETCH 2.1.1.1.1
...

Error:
1 1 1 0