| Task: | Bittijono |
| Sender: | Shrike |
| Submission time: | 2016-10-10 09:00:02 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | 1 | details |
| #2 | RUNTIME ERROR | 0.26 s | 2 | details |
| #3 | RUNTIME ERROR | 0.31 s | 3 | details |
Compiler report
input/code.cpp: In function 'int solve(ll)':
input/code.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
input/code.cpp:29:3: warning: 'is_a' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (is_a) {
^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;
int atoi (string c) {
stringstream s;
int i;
s << c;
s >> i;
return i;
}
int
solve (ll i) {
bool is_a;
int a[4] = {0, 1, 1, 0};
int b[4] = {1, 0, 0, 1};
ll max = (ll)pow (2.0, 60.0);
int j;
for (j = 0; j < 30; j++) {
if (is_a) {
if (j == 29) {
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/4;
} else if (i > 2*(max/4) && i < 3*(max/4)) {
is_a = false;
max = max/4;
i -= 2*(max/4);
} else {
is_a = true;
max = max/4;
i -= 3*(max/4);
}
}
} else {
if (j == 29) {
return b[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/4;
} else if (i > 2*(max/4) && i < 3*(max/4)) {
is_a = false;
max = max/4;
i -= 2*(max/4);
} else {
is_a = true;
max = max/4;
i -= 3*(max/4);
}
}
}
}
}
int
main ()
{
string num_s;
int num, i;
cin >> num_s;
num = atoi (num_s);
vector<int> input(num);
for (i = 0; i < num; i++) {
num_s = "";
cin >> num_s;
input[i] = (ll)atoi (num_s) -1;
}
for (i = 0; i < num; i++)
cout << solve (input[i]) << "\n";
return 0;
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 62 9 12 73 ... |
| correct output |
|---|
| 1 1 1 0 1 ... |
| user output |
|---|
| 4198736 0 0 0 1 ... |
Test 2
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 565433 141881 120108 825392 ... |
| correct output |
|---|
| 1 1 0 0 1 ... |
| user output |
|---|
| (empty) |
Test 3
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 374768524402011755 937067109466254318 389256426086302899 932585725667010169 ... |
| correct output |
|---|
| 0 1 1 1 1 ... |
| user output |
|---|
| (empty) |
