제출 #109635

#제출 시각아이디문제언어결과실행 시간메모리
109635youssefbou62콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define pb push_back string guess_sequence (int n){ string buttons ,s; if( press("A")==1 ) s.pb('A') , buttons = "BXY" ; else if( press("B")==1 ) s.pb('B') , buttons = "AXY" ; else if( press("X")==1 ) s.pb('X') , buttons = "ABY" ; else s.pb('Y' ) , buttons = "ABX" ; while ( (int)s.length() != n ){ string s2 = s ; for(int i = 0 ; i < 4*n-s.length() ; i++ ) s2.pb(buttons[0]); int ans = press ( s2 ) ; if( ans > (int)s.length() ) while ( ans > (int)s.length() ) s.pb(buttons[0]) ; else { s2=s ; for(int i = 0 ; i < 4*n-s.length() ; i++ ) s2.pb(buttons[1]); ans = press ( s2 ) ; if( ans > (int)s.lenght() ) { while ( ans > (int)s.length() ) s.pb(buttons[1]) ; } else { s2=s ; s.pb(buttons[2]) ; } } } assert( (int)s.length() == n) ; return s ; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i = 0 ; i < 4*n-s.length() ; i++ ) s2.pb(buttons[0]);
      |                   ~~^~~~~~~~~~~~~~~~
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i = 0 ; i < 4*n-s.length() ; i++ ) s2.pb(buttons[1]);
      |                   ~~^~~~~~~~~~~~~~~~
combo.cpp:29:20: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'lenght'; did you mean 'length'?
   29 |   if( ans > (int)s.lenght() ) {
      |                    ^~~~~~
      |                    length