제출 #1302859

#제출 시각아이디문제언어결과실행 시간메모리
1302859antarbanik콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; /* A B X Y -> ei 4 ta button ache game er ekta secret sequence of buttons ache -> s s oi ta button diya toiri S er first character ta abar reappears hoy na S, P press() function ta return korbo longest prefix of S that is also a substr of P */ // p: seq of buttons that i press. // len of p [0,4N] // 8000 bar er besi ei function ta call kora jaito na // amare oi string ta implement kora lagbo // N = len of string S string guess_sequence(int N){ string ans; for(int i = 0;i<=26;++i){ char c = 'a' + i; if(press(c) == 1){ ans.push_back(c); break; } } bool f = 0; for(int i = 0;i<=26;++i){ char c = 'a' + i; string temp; temp.push_back(ans); temp.push_back(c); if(press(temp) == 2){ ans.push_back(c); f = 1; break; } } if(!f){ return ans; } f = 0; for(int i = 0;i<=26;++i){ char c = 'a' + i; string t#include "combo.h" #include <bits/stdc++.h> using namespace std; /* A B X Y -> ei 4 ta button ache game er ekta secret sequence of buttons ache -> s s oi ta button diya toiri S er first character ta abar reappears hoy na S, P press() function ta return korbo longest prefix of S that is also a substr of P */ // p: seq of buttons that i press. // len of p [0,4N] // 8000 bar er besi ei function ta call kora jaito na // amare oi string ta implement kora lagbo // N = len of string S string guess_sequence(int N){ string ans; for(int i = 0;i<=26;++i){ char c = 'a' + i; string temp; temp.push_back(c); if(press(temp) == 1){ ans.push_back(c); break; } } bool f = 0; for(int i = 0;i<=26;++i){ char c = 'a' + i; string temp; temp.push_back(ans); temp.push_back(c); if(press(temp) == 2){ ans.push_back(c); f = 1; break; } } if(!f){ return ans; } f = 0; for(int i = 0;i<=26;++i){ char c = 'a' + i; string temp; temp.ppush_back(ans); temp.push_back(c); if(press(temp) == 3){ ans.push_back(c); f = 1; break; } } return ans; } emp; temp.ppush_back(ans); temp.push_back(c); if(press(temp) == 3){ ans.push_back(c); f = 1; break; } } return ans; }

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

combo.cpp:74:17: error: stray '#' in program
   74 |         string t#include "combo.h"
      |                 ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:18: error: could not convert 'c' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   48 |         if(press(c) == 1){
      |                  ^
      |                  |
      |                  char
combo.cpp:58:24: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char'
   58 |         temp.push_back(ans);
      |                        ^~~
      |                        |
      |                        std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/13/string:54,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/13/bits/basic_string.h:1561:24: note:   initializing argument 1 of 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1561 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~
combo.cpp:74:18: error: expected initializer before 'include'
   74 |         string t#include "combo.h"
      |                  ^~~~~~~
combo.cpp:116:29: error: a function-definition is not allowed here before '{' token
  116 | string guess_sequence(int N){
      |                             ^
combo.cpp:166:1: error: 'emp' was not declared in this scope; did you mean 'exp'?
  166 | emp;
      | ^~~
      | exp
combo.cpp:167:9: error: 'temp' was not declared in this scope; did you mean 'tm'?
  167 |         temp.ppush_back(ans);
      |         ^~~~
      |         tm