Submission #1272612

#TimeUsernameProblemLanguageResultExecution timeMemory
1272612pvpwarriorParrots (IOI11_parrots)C++20
Compilation error
0 ms0 KiB
void encode(int N, int M[]){
    int C = 0;
    send(C);
    for (int i = 0; i < N; ++i)
    {
        M[i]++;
        string s = "";
        while(M[i]){
            if (M[i]%2)
            {
                s+="1";
            }
            else{
                s+="0";
            }
            M[i]/=2;
        }
        reverse(s.begin(), s.end());
        // cout << s << " ";
        for (auto x: s){
            if(x=='1'){
                C++;
            }
            send(C);
        }
        C+=2;
    }
    return;
}

void decode(int N, int L, int X[]){
    sort(X, X+L);
    string s = "";
    for (int i = 1; i < L; ++i)
    {
        if (X[i]==X[i-1])
        {
            s += "0";
        }
        else if(X[i]==X[i-1]+1){
            s += "1";
        }
        else{
            int C = std::stoi(s, nullptr, 2);
            output(C-1);
            s = "";
            if (X[i]==X[i-1]+2)
            {
                s = "0";
            }
            else{
                s = "1";
            }
        }
    }
    int C = std::stoi(s, nullptr, 2);
    output(C-1);
    return;
}

Compilation message (stderr)

# 1번째 컴파일 단계

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:3:5: error: 'send' was not declared in this scope
    3 |     send(C);
      |     ^~~~
encoder.cpp:7:9: error: 'string' was not declared in this scope
    7 |         string s = "";
      |         ^~~~~~
encoder.cpp:11:17: error: 's' was not declared in this scope
   11 |                 s+="1";
      |                 ^
encoder.cpp:14:17: error: 's' was not declared in this scope
   14 |                 s+="0";
      |                 ^
encoder.cpp:18:17: error: 's' was not declared in this scope
   18 |         reverse(s.begin(), s.end());
      |                 ^
encoder.cpp:18:9: error: 'reverse' was not declared in this scope
   18 |         reverse(s.begin(), s.end());
      |         ^~~~~~~