CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:Shrike
Submission time:2016-10-11 08:16:25 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED19
#3ACCEPTED71
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.18 s2details
#3ACCEPTED0.24 s3details

Code

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cmath>
typedef long long ll;
/* ABBA BAAB BAAB ABBA BAAB ABBA ABBA BAAAB */
using namespace std;
ll atol (string c) {
stringstream s;
ll i;
s << c;
s >> i;
return i;
}
int
solve (ll i) {
bool is_a = true;
int a[12] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1};
int b[12] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0};
/* if (i == 80)
return 0; */
ll max = (ll)pow (4.0, 30.0);
for (;;) {
// cout << is_a << " " << i << " " << max << endl;
if (is_a) {
if (i < 12) {
return a[i];
} else {
if (i < max/4) {
is_a = true;
max = max/4;
} else if (i >= max/4 && i < 2*(max/4)) {
is_a = false;
max = max/4;
i -= max;
} else if (i >= 2*(max/4) && i < 3*(max/4)) {
is_a = false;
max = max/4;
i -= 2*max;
} else {
is_a = true;
max = max/4;
i -= 3*max;
}
}
} else {
if (i < 12) {
return b[i];
} else {
if (i < max/4) {
is_a = false;
max = max/4;
} else if (i >= max/4 && i < 2*(max/4)) {
is_a = true;
max = max/4;
i -= max;
} else if (i >= 2*(max/4) && i < 3*(max/4)) {
is_a = true;
max = max/4;
i -= 2*max;
} else {
is_a = false;
max = max/4;
i -= 3*max;
}
}
}
}
return 0;
}
int
main ()
{
string num_s;
ll num, i;
cin >> num_s;
num = atol (num_s);
vector<ll> input(num);
for (i = 0; i < num; i++) {
num_s = "";
cin >> num_s;
input[i] = atol (num_s);
}
for (i = 0; i < num; i++)
cout << solve (input[i]-1) << "\n";
return 0;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
100
62
9
12
73
...

correct output
1
1
1
0
1
...

user output
1
1
1
0
1
...

Test 2

Group: 2

Verdict: ACCEPTED

input
100000
565433
141881
120108
825392
...

correct output
1
1
0
0
1
...

user output
1
1
0
0
1
...

Test 3

Group: 3

Verdict: ACCEPTED

input
100000
374768524402011755
937067109466254318
389256426086302899
932585725667010169
...

correct output
0
1
1
1
1
...

user output
0
1
1
1
1
...