Submission #320285

#TimeUsernameProblemLanguageResultExecution timeMemory
320285spatarelMartian DNA (IOI16_dna)C++17
100 / 100
12 ms640 KiB
#include "dna.h" #include <cstdlib> std::string letters[] = {"0", "1"}; std::string analyse(int n, int t) { std::string S = ""; int doubts = 0; while (doubts < 19) { int guess = rand() % 2; std::string testS = letters[guess] + S; if (make_test(testS)) { S = letters[guess] + S; doubts = 0; } else { S = letters[1 - guess] + S; doubts++; } } for (int step = 16; step > 0; step /= 2) { if ((int)S.size() > step) { std::string testS = S.substr(step); if (!make_test(testS)) { S = S.substr(step); } } } S = S.substr(1); while ((int)S.size() < n) { int guess = rand() % 2; std::string testS = S + letters[guess]; if (make_test(testS)) { S = S + letters[guess]; } else { S = S + letters[1 - guess]; } } return S; }

Compilation message (stderr)

grader.cpp: In function 'bool make_test(std::string)':
grader.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < p.size(); i++) {
      |                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i = 1; i <= ss.size(); i++) {
      |                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (pr[i] == p.size()) {
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...