답안 #883461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883461 2023-12-05T10:00:21 Z dejandenib 앵무새 (IOI11_parrots) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"

long long mapa2[92400];

int broj = 0;
map<long long ,int> mapa;

void rec(int posledno, int n, long long  s,int depth){

    if(depth==n)
    {
        mapa[s]=broj;
         //       mapa2[broj]=s;

        //cout<<s<<" "<<broj<<endl;
        broj++;
        return;
    }
    for(long long i =posledno;i<n;i++)
    {

        rec(i,n,s*10LL+i,depth+1);

    }
}
void rec2(int posledno, int n, long long  s,int depth){

    if(depth==n)
    {
        //mapa[s]=broj;
                mapa2[broj]=s;

        //cout<<s<<" "<<broj<<endl;
        broj++;
        return;
    }
    for(long long i =posledno;i<n;i++)
    {

        rec2(i,n,s*10LL+i,depth+1);

    }
}

void encode(int n, int a[])
{
    rec2(0,10,0,0);

    int nn = n;
    if (nn%2==1)
        nn++;

    int b[nn*8];

    int suma=0;
    int start_from = 0;
    for(int i =0;i<n;i++)
    {


      if (i%2==0)
        suma = a[i];
      else
        suma = (suma<<8)+a[i];

        if (i%2==1 || i==n-1)
        {
            if (i==n-1 && n%2==1)
                suma<<=8;

            string s= "";

            long long x= mapa2[suma];

            while (x>0)
            {
                s=(char)(x%10 + '0') + s;
                x/=10;

            }
            while (s.size()<10)
                s="0"+s;
          //  cout<<s<<endl;
            int array_to_send[10];
            for(int j =0;j<10;j++)
            {
                int brojce = (int)(s[j]-'0');
                send(start_from+brojce);
              //  if (i==n-1 && n%2==1 && j==4)
                  //  break;

            }
            start_from+=10;

            suma=0;
        }

    }
}
#include <bits/stdc++.h>

#include "decoder.h"
#include "decoderlib.h"
long long mapa2[92400];

int broj = 0;
map<long long ,int> mapa;

void rec(int posledno, int n, long long  s,int depth){

    if(depth==n)
    {
        mapa[s]=broj;
         //       mapa2[broj]=s;

        //cout<<s<<" "<<broj<<endl;
        broj++;
        return;
    }
    for(long long i =posledno;i<n;i++)
    {

        rec(i,n,s*10LL+i,depth+1);

    }
}
void rec2(int posledno, int n, long long  s,int depth){

    if(depth==n)
    {
        //mapa[s]=broj;
                mapa2[broj]=s;

        //cout<<s<<" "<<broj<<endl;
        broj++;
        return;
    }
    for(long long i =posledno;i<n;i++)
    {

        rec2(i,n,s*10LL+i,depth+1);

    }
}

void decode(int n,int howmany2,int a[]){

    broj = 0;
    rec(0,10,0,0);

    sort(a,a+howmany2);
    /*        for(int i =0;i<howmany2;i++)
        cout<<a[i]<<" ";
    cout<<endl;*/
    long long s=0;
    int mod = 1<<8;
    int start_from = 0;
    for(int i =0;i<howmany2;i++)
    {
        s=s*10LL+ (long long)(a[i]-start_from);
        if (i%10==9 || i==howmany2-1)
        {

            //cout<<s<<endl;
            //if (i==howmany2-1 && n%2==1)
            //for(int j =0;j<5;j++)
          //      s+=s[5];

            int converted = mapa[s];

            output(converted/mod);

            if (i==howmany2-1 && n%2==1)
                break;

            output(converted%mod);

            start_from+=10;
            s=0;

        }
    }
}

Compilation message

encoder.cpp:8:1: error: 'map' does not name a type; did you mean 'mapa2'?
    8 | map<long long ,int> mapa;
      | ^~~
      | mapa2
encoder.cpp: In function 'void rec(int, int, long long int, int)':
encoder.cpp:14:9: error: 'mapa' was not declared in this scope; did you mean 'mapa2'?
   14 |         mapa[s]=broj;
      |         ^~~~
      |         mapa2
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:65:7: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   65 |       else
      |       ^~~~
encoder.cpp:68:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   68 |         if (i%2==1 || i==n-1)
      |         ^~
encoder.cpp:73:13: error: 'string' was not declared in this scope
   73 |             string s= "";
      |             ^~~~~~
encoder.cpp:73:13: note: suggested alternatives:
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from encoder.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from encoder.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
encoder.cpp:79:17: error: 's' was not declared in this scope
   79 |                 s=(char)(x%10 + '0') + s;
      |                 ^
encoder.cpp:83:20: error: 's' was not declared in this scope
   83 |             while (s.size()<10)
      |                    ^
encoder.cpp:89:36: error: 's' was not declared in this scope
   89 |                 int brojce = (int)(s[j]-'0');
      |                                    ^
encoder.cpp:86:17: warning: unused variable 'array_to_send' [-Wunused-variable]
   86 |             int array_to_send[10];
      |                 ^~~~~~~~~~~~~
encoder.cpp:55:9: warning: unused variable 'b' [-Wunused-variable]
   55 |     int b[nn*8];
      |         ^

decoder.cpp:8:1: error: 'map' does not name a type; did you mean 'mapa2'?
    8 | map<long long ,int> mapa;
      | ^~~
      | mapa2
decoder.cpp: In function 'void rec(int, int, long long int, int)':
decoder.cpp:14:9: error: 'mapa' was not declared in this scope; did you mean 'mapa2'?
   14 |         mapa[s]=broj;
      |         ^~~~
      |         mapa2
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:52:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   52 |     sort(a,a+howmany2);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from decoder.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
decoder.cpp:70:29: error: 'mapa' was not declared in this scope; did you mean 'mapa2'?
   70 |             int converted = mapa[s];
      |                             ^~~~
      |                             mapa2