제출 #701031

#제출 시각아이디문제언어결과실행 시간메모리
701031BobCompetitiveProgramming콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; int press(std::string p); string getRandom(string start, string no, int sz){ while(start.size() < sz){ int r = rand() % 4 + 1; if(r==1 && "A" != no) start += "A"; if(r==2 && "B" != no) start += "B"; if(r==3 && "X" != no) start += "X"; if(r==4 && "Y" != no) start += "Y"; } return start; } string guess_sequence(int N){ string S = "", first; vector<string> buttons{"A", "B", "X", "Y"}; for(auto& button : buttons) if(button=="Y" || press(button)){ first = button, S += button; break; } while(true){ if(S.size() == N) return S; for(auto& button : buttons) { if(button == first) continue; if(button=="Y" || (first=="Y" && button=="X")) { S += button; break; } string ra = getRandom(button, first, min(S.size(), 4*N-S.size())); int ret = press(S+ra); if(ret>S.size()) S += ra.substr(0, ret-S.size()); } } } int press(string s){ cout << " IN PRESS, ans with string s = " << s << endl; ll ret; cin>>ret; return ret; } int main(){ guess_sequence(5); }

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

combo.cpp: In function 'std::string getRandom(std::string, std::string, int)':
combo.cpp:8:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |     while(start.size() < sz){
      |           ~~~~~~~~~~~~~^~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(S.size() == N)
      |            ~~~~~~~~~^~~~
combo.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if(ret>S.size())
      |                ~~~^~~~~~~~~
/usr/bin/ld: /tmp/ccQIwvNt.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/cc47ug5u.o:combo.cpp:(.text+0x340): first defined here
/usr/bin/ld: /tmp/ccQIwvNt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc47ug5u.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status