CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:3isagreatnumber
Submission time:2016-10-05 13:15:21 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:29:17: error: 's' was not declared in this scope
         cout << s[ks[i]-1] << '\n';
                 ^

Code

#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#define ull unsigned long long

using namespace std;

string gen(ull);
string inv(string);

int main(void)
{
    int n;
    cin >> n;
    vector<int> ks;

    int max = 0;
    int k;
    for (int i = 0; i < n; i++)
    {
        cin >> k;
        ks.push_back(k);
        if (k > max) max = k;
    }

    for (int i = 0; i < n; i++)
    {
        cout << s[ks[i]-1] << '\n';
    }
}

string gen(ull k_max)
{
    int n = ceil(log(float(k_max))/log(2.0)+1);

    string s = "0";
    for (int i = 1; i < n; i++)
    {
        s+=inv(s);
    }
    return s;
}

string inv(string s)
{
    for (int i = 0, l = s.length(); i < l; i++)
    {
        if (s[i] == '1') s[i] = '0';
        else s[i] = '1';
    }
    return s;
}