제출 #1006655

#제출 시각아이디문제언어결과실행 시간메모리
1006655devariaota콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; # define int long long # define fir first # define sec second # define pb push_back # define endl "\n" std::string guess_sequence(int N) { char ch[3]; string st; int asd = press("AB"); if(asd) { int x = press("A"); if(x) st = "A", ch = {'B', 'X', 'Y'}; else st = "B", ch = {'A', 'X', 'Y'}; } else { int x = press("X"); if(x) st = "X", ch = {'A', 'B', 'Y'}; else st = "Y", ch = {'A', 'B', 'X'}; } for(int i = 2; i<N; i++) { string now = ""; now += st; now.pb(ch[0]); now.pb(ch[0]); now += st; now.pb(ch[0]); now.pb(ch[1]); now += st; now.pb(ch[0]); now.pb(ch[2]); now += st; now.pb(ch[1]); int get = press(now); if(get == i+1) st.pb(ch[0]); else if(get == i) st.pb(ch[1]); else st.pb(ch[2]); } int st0 = st; st0.pb(ch[0]); int st1 = st; st1.pb(ch[1]); int st2 = st; st2.pb(ch[2]); int x = press(st0); int y = press(st1); int z = press(st2); if(x == N) st.pb(ch[0]); else if(y == N) st.pb(ch[1]); else st.pb(ch[2]); return st; }

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(long long int)':
combo.cpp:17:28: error: assigning to an array from an initializer list
   17 |         if(x) st = "A", ch = {'B', 'X', 'Y'};
      |                         ~~~^~~~~~~~~~~~~~~~~
combo.cpp:18:27: error: assigning to an array from an initializer list
   18 |         else st = "B", ch = {'A', 'X', 'Y'};
      |                        ~~~^~~~~~~~~~~~~~~~~
combo.cpp:22:28: error: assigning to an array from an initializer list
   22 |         if(x) st = "X", ch = {'A', 'B', 'Y'};
      |                         ~~~^~~~~~~~~~~~~~~~~
combo.cpp:23:27: error: assigning to an array from an initializer list
   23 |         else st = "Y", ch = {'A', 'B', 'X'};
      |                        ~~~^~~~~~~~~~~~~~~~~
combo.cpp:38:15: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long long int' in initialization
   38 |     int st0 = st; st0.pb(ch[0]);
      |               ^~
      |               |
      |               std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:8:13: error: request for member 'push_back' in 'st0', which is of non-class type 'long long int'
    8 | # define pb push_back
      |             ^~~~~~~~~
combo.cpp:38:23: note: in expansion of macro 'pb'
   38 |     int st0 = st; st0.pb(ch[0]);
      |                       ^~
combo.cpp:39:15: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long long int' in initialization
   39 |     int st1 = st; st1.pb(ch[1]);
      |               ^~
      |               |
      |               std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:8:13: error: request for member 'push_back' in 'st1', which is of non-class type 'long long int'
    8 | # define pb push_back
      |             ^~~~~~~~~
combo.cpp:39:23: note: in expansion of macro 'pb'
   39 |     int st1 = st; st1.pb(ch[1]);
      |                       ^~
combo.cpp:40:15: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long long int' in initialization
   40 |     int st2 = st; st2.pb(ch[2]);
      |               ^~
      |               |
      |               std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:8:13: error: request for member 'push_back' in 'st2', which is of non-class type 'long long int'
    8 | # define pb push_back
      |             ^~~~~~~~~
combo.cpp:40:23: note: in expansion of macro 'pb'
   40 |     int st2 = st; st2.pb(ch[2]);
      |                       ^~
combo.cpp:42:19: error: could not convert 'st0' from 'long long int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   42 |     int x = press(st0);
      |                   ^~~
      |                   |
      |                   long long int
combo.cpp:43:19: error: could not convert 'st1' from 'long long int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   43 |     int y = press(st1);
      |                   ^~~
      |                   |
      |                   long long int
combo.cpp:44:19: error: could not convert 'st2' from 'long long int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   44 |     int z = press(st2);
      |                   ^~~
      |                   |
      |                   long long int
combo.cpp:44:9: warning: unused variable 'z' [-Wunused-variable]
   44 |     int z = press(st2);
      |         ^