답안 #603723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
603723 2022-07-24T10:24:15 Z Abdulmohsen1284 Flight to the Ford (BOI22_communication) C++17
컴파일 오류
0 ms 0 KB
#include"communication.h"
//
// --- Sample implementation for the task communication ---
//
// To compile this program with the sample grader, place:
//     communication.h communication_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
//     g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//


void encode(int N, int X) {
#include <bits/stdc++.h>
using namespace std;
    long long twos[40],n[40],x[40];
    twos[0]=1;
    for(int i=1;i<=32;i++)
        twos[i]=twos[i-1]*2;
    for(int i=1;i>=0;i--)
    {
        if(N>=twos[i])
        {
            n[i]=1;
            N-=twos[i];
        }
        if(X>=twos[i])
        {
            x[i]=1;
            X-=twos[i];
        }
    }
    long long bef=send(1),rev=0,calc=1;
    for(int i=0;i<2;i++)
    {
        //if(bef==-1)
        //long long bef=send(1);
        //cout<<n[i]<<endl<<i<<endl;
        long long e,w;
        while(calc>240)
        {
            calc=calc;
        }
        if(rev%2==0)
        {
            calc+=2;
            e=send(n[i]);
            w=send(n[i]);
        }
        else
        {
            calc+=2;
            w=send(n[i]);
            e=send(n[i]);
        }
        calc++;
        long long hg=send(1);
        if(bef==0)
        {
            bef=bef;
        }
        else if(hg==0)
        {
            hg=hg;
        }
        else if(e==w)
        {
            hg=hg;
        }
        
        else{
            rev++;
            i--;
            continue;
        }
        bef=hg;
    }
    for(int i=0;i<2;i++)
    {
        long long e,w;
        //cout<<x[i]<<endl<<i<<endl;
        while(calc>240)
        {
            calc=calc;
        }
        if(rev%2==0)
        {
            calc+=2;
            e=send(x[i]);
            w=send(x[i]);
        }
        else
        {
            calc+=2;
            w=send(x[i]);
            e=send(x[i]);
        }
        calc++;
        long long hg=send(1);
        if(bef==0)
        {
            bef=bef;
        }
        else if(hg==0)
        {
            hg=hg;
        }
        else if(e==w)
        {
            hg=hg;
        }
        else{
            rev++;
            i--;
            continue;
        }
        bef=hg;
    }
    //X=send(1);
}

std::pair<int, int> decode(int N) {
    #include <bits/stdc++.h>
using namespace std;
    long long tw[40],rev=0;
    tw[0]=1;
    for(int i=1;i<=32;i++)
        tw[i]=tw[i-1]*2;
    long long bef=-1;
    pair <int,int> ret;
    ret.first=0;
    ret.second=0;
    bef=receive();
    for(int i=0;i<2;i++)
    {
        long long e,g;
        if(rev%2==0)
        {
            g=receive();
            e=receive();
        }
        else
        {
            e=receive();
            g=receive();
        }
        long long w=receive();
        if(bef==0)
        {
            ret.first+=g*tw[i];
        }
        else if(w==0)
        {
            ret.first+=e*tw[i];
        }
        else if(g==e)
        {
            ret.first+=g*tw[i];
        }
        else{
            rev++;
            i--;
            continue;
        }
        bef=w;
    }
    for(int i=0;i<2;i++)
    {
        //long long g=receive(),e=receive(),w=receive();
        long long e,g;
        if(rev%2==0)
        {
            g=receive();
            e=receive();
        }
        else
        {
            e=receive();
            g=receive();
        }
        long long w=receive();
        if(bef==0)
        {
            ret.second+=g*tw[i];
        }
        else if(w==0)
        {
            ret.second+=e*tw[i];
        }
        else if(g==e)
        {
            ret.second+=g*tw[i];
        }
        else{
            rev++;
            i--;
            continue;
        }
        bef=w;
    }
    long long st=ret.first,en=ret.second;
    //cout<<ret.first<<" "<<ret.second;
    return ret;
}

Compilation message

In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/assert.h: In function 'void encode(int, int)':
/usr/include/assert.h:66:1: error: expected unqualified-id before string constant
   66 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/ctype.h:28:1: error: expected unqualified-id before string constant
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:35,
                 from communication.cpp:17:
/usr/include/c++/10/cctype:62:1: error: 'namespace' definition is not allowed here
   62 | namespace std
      | ^~~~~~~~~
/usr/include/c++/10/cctype:85:1: error: 'namespace' definition is not allowed here
   85 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/errno.h:34:1: error: expected unqualified-id before string constant
   34 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/locale.h:31:1: error: expected unqualified-id before string constant
   31 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:40,
                 from communication.cpp:17:
/usr/include/c++/10/clocale:51:1: error: 'namespace' definition is not allowed here
   51 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/c++/10/cmath:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:17:
/usr/include/c++/10/bits/cpp_type_traits.h:67:8: error: expected unqualified-id before string constant
   67 | extern "C++" {
      |        ^~~~~
In file included from /usr/include/c++/10/cmath:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:17:
/usr/include/c++/10/ext/type_traits.h:37:8: error: expected unqualified-id before string constant
   37 | extern "C++" {
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/math.h:34:1: error: expected unqualified-id before string constant
   34 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/stdlib.h:33:1: error: expected unqualified-id before string constant
   33 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:17:
/usr/include/c++/10/bits/std_abs.h:46:8: error: expected unqualified-id before string constant
   46 | extern "C++"
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:17:
/usr/include/c++/10/cmath:77:8: error: expected unqualified-id before string constant
   77 | extern "C++"
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/setjmp.h:27:1: error: expected unqualified-id before string constant
   27 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:42,
                 from communication.cpp:17:
/usr/include/c++/10/csetjmp:55:1: error: 'namespace' definition is not allowed here
   55 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/signal.h:27:1: error: expected unqualified-id before string constant
   27 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:43,
                 from communication.cpp:17:
/usr/include/c++/10/csignal:50:1: error: 'namespace' definition is not allowed here
   50 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:44,
                 from communication.cpp:17:
/usr/include/c++/10/cstdarg:53:1: error: 'namespace' definition is not allowed here
   53 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from communication.cpp:17:
/usr/include/c++/10/cstddef:52:8: error: expected unqualified-id before string constant
   52 | extern "C++"
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/stdio.h:29:1: error: expected unqualified-id before string constant
   29 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:46,
                 from communication.cpp:17:
/usr/include/c++/10/cstdio:96:1: error: 'namespace' definition is not allowed here
   96 | namespace std
      | ^~~~~~~~~
/usr/include/c++/10/cstdio:157:1: error: 'namespace' definition is not allowed here
  157 | namespace __gnu_cxx
      | ^~~~~~~~~
/usr/include/c++/10/cstdio:183:1: error: 'namespace' definition is not allowed here
  183 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:47,
                 from communication.cpp:17:
/usr/include/c++/10/cstdlib:121:8: error: expected unqualified-id before string constant
  121 | extern "C++"
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/string.h:28:1: error: expected unqualified-id before string constant
   28 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from communication.cpp:17:
/usr/include/c++/10/cstring:71:8: error: expected unqualified-id before string constant
   71 | extern "C++"
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/time.h:73,
                 from /usr/include/time.h:33,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from communication.cpp:17:
/usr/include/x86_64-linux-gnu/bits/timex.h:37:18: error: field 'time' has incomplete type 'encode(int, int)::timeval'
   37 |   struct timeval time;  /* (read only, except for ADJ_SETOFFSET) */
      |                  ^~~~
/usr/include/x86_64-linux-gnu/bits/timex.h:37:10: note: forward declaration of 'struct encode(int, int)::timeval'
   37 |   struct timeval time;  /* (read only, except for ADJ_SETOFFSET) */
      |          ^~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/x86_64-linux-gnu/bits/time.h:75:1: error: expected unqualified-id before string constant
   75 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/time.h:48,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from communication.cpp:17:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:10:21: error: field 'it_interval' has incomplete type 'encode(int, int)::timespec'
   10 |     struct timespec it_interval;
      |                     ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:10:12: note: forward declaration of 'struct encode(int, int)::timespec'
   10 |     struct timespec it_interval;
      |            ^~~~~~~~
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:11:21: error: field 'it_value' has incomplete type 'encode(int, int)::timespec'
   11 |     struct timespec it_value;
      |                     ^~~~~~~~
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:10:12: note: forward declaration of 'struct encode(int, int)::timespec'
   10 |     struct timespec it_interval;
      |            ^~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/time.h:68:1: error: expected unqualified-id before string constant
   68 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from communication.cpp:17:
/usr/include/c++/10/ctime:58:1: error: 'namespace' definition is not allowed here
   58 | namespace std
      | ^~~~~~~~~
/usr/include/c++/10/ctime:77:1: error: 'namespace' definition is not allowed here
   77 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/wchar.h:42,
                 from /usr/include/c++/10/cwchar:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:50,
                 from communication.cpp:17:
/usr/include/x86_64-linux-gnu/bits/types/mbstate_t.h:6:9: error: '__mbstate_t' does not name a type
    6 | typedef __mbstate_t mbstate_t;
      |         ^~~~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/wchar.h:79:1: error: expected unqualified-id before string constant
   79 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:50,
                 from communication.cpp:17:
/usr/include/c++/10/cwchar:62:1: error: 'namespace' definition is not allowed here
   62 | namespace std
      | ^~~~~~~~~
/usr/include/c++/10/cwchar:135:8: error: expected unqualified-id before string constant
  135 | extern "C++"
      |        ^~~~~
/usr/include/c++/10/cwchar:244:1: error: 'namespace' definition is not allowed here
  244 | namespace __gnu_cxx
      | ^~~~~~~~~
/usr/include/c++/10/cwchar:265:1: error: 'namespace' definition is not allowed here
  265 | namespace std
      | ^~~~~~~~~
/usr/include/c++/10/cwchar:280:1: error: 'namespace' definition is not allowed here
  280 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/x86_64-linux-gnu/bits/wctype-wchar.h:87:1: error: expected unqualified-id before string constant
   87 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/wctype.h:44:1: error: expected unqualified-id before string constant
   44 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:51,
                 from communication.cpp:17:
/usr/include/c++/10/cwctype:80:1: error: 'namespace' definition is not allowed here
   80 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from communication.cpp:17:
/usr/include/c++/10/ccomplex:38:8: error: expected unqualified-id before string constant
   38 | extern "C++" {
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/x86_64-linux-gnu/bits/fenv.h:120:1: error: expected unqualified-id before string constant
  120 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/fenv.h:66:1: error: expected unqualified-id before string constant
   66 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cfenv:41,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:55,
                 from communication.cpp:17:
/usr/include/c++/10/fenv.h:55:1: error: 'namespace' definition is not allowed here
   55 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:55,
                 from communication.cpp:17:
/usr/include/c++/10/cfenv:58:1: error: 'namespace' definition is not allowed here
   58 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/inttypes.h:266:1: error: expected unqualified-id before string constant
  266 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:56,
                 from communication.cpp:17:
/usr/include/c++/10/cinttypes:55:1: error: 'namespace' definition is not allowed here
   55 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:60,
                 from communication.cpp:17:
/usr/include/c++/10/ctgmath:38:8: error: expected unqualified-id before string constant
   38 | extern "C++" {
      |        ^~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/uchar.h:41:1: error: expected unqualified-id before string constant
   41 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/c++/10/cuchar:61:15: error: expected '=' before '__attribute__'
   61 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/cuchar:61:15: error: expected identifier before '__attribute__'
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:61,
                 from communication.cpp:17:
/usr/include/c++/10/cuchar:61:14: error: expected ';' before '__attribute__'
   61 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/10/cuchar:62:1: error: expected primary-expression before '{' token
   62 | {
      | ^
In file included from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/c++/10/bits/algorithmfwd.h:42:15: error: expected '=' before '__attribute__'
   42 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/algorithmfwd.h:42:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/10/bits/stl_algo.h:60,
                 from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:17:
/usr/include/c++/10/bits/algorithmfwd.h:42:14: error: expected ';' before '__attribute__'
   42 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/10/bits/algorithmfwd.h:43:1: error: expected primary-expression before '{' token
   43 | {
      | ^
In file included from /usr/include/c++/10/utility:68,
                 from communication.h:1,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_heap.h:62:15: error: expected '=' before '__attribute__'
   62 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_heap.h:62:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/10/bits/stl_algo.h:61,
                 from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from /var/local/lib/isolate/750/box/