Submission #132097

#TimeUsernameProblemLanguageResultExecution timeMemory
132097Tuk1352Combo (IOI18_combo)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int press(string p) { int r; cout << p << endl; cin >> r; return r; } string guess_sequence(int N) { int r; string s1, s2, s3, s4, s, S; map <int, char> Ma; Ma[0] = 'A'; Ma[1] = 'B'; Ma[2] = 'X'; Ma[3] = 'Y'; s = "AB"; r = press(s); if (r >= 1) { s = "A"; r = press(s); if (r == 0) { Ma[1] = 'A'; Ma[0] = 'B'; S = "B"; } else { S = "A"; } } else { s = "X"; r = press(s); if (r == 1) { Ma[0] = 'X'; Ma[2] = 'A'; S = "X"; } else { Ma[0] = 'Y'; Ma[3] = 'A'; S = "Y"; } } for (int i = 1; i < N-1; i++) { s1 = S + Ma[1]; s2 = S + Ma[2] + Ma[1]; s3 = S + Ma[2] + Ma[2]; s4 = S + Ma[2] + Ma[3]; s = s1 + s2 + s3 + s4; r = press(s); if (r == S.length()) { S += Ma[3]; } else if (r == S.length() + 1) { S += Ma[1]; } else { S += Ma[2]; } } s = S + Ma[1]; r = press(s); if (r == N) { S += Ma[1]; return S; } s = S + Ma[2]; r = press(s); if (r == N) { S += Ma[2]; return S; } S += Ma[3]; return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:64:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if (r == S.length())
      |             ~~^~~~~~~~~~~~~
combo.cpp:68:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         else if (r == S.length() + 1)
      |                  ~~^~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccFAYdAj.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/ccz99byk.o:combo.cpp:(.text+0x270): first defined here
collect2: error: ld returned 1 exit status