Submission #335531

#TimeUsernameProblemLanguageResultExecution timeMemory
335531aintaMartian DNA (IOI16_dna)C++17
100 / 100
16 ms492 KiB
#include "dna.h" #include <cstdlib> #include <string> using namespace std; std::string analyse(int n, int t) { int b = 1, e = n, r = 0; int i, j; while(b<=e){ int mid = (b+e)>>1; string s = ""; for(i=0;i<mid;i++)s+='0'; if(make_test(s)){ r=mid; b=mid+1; } else e=mid-1; } string s = ""; for(i=0;i<r;i++)s+='0'; int ck=0; for(i=0;;i++){ s+='1'; if(make_test(s))ck=0; else{ s.pop_back(); s+='0'; ck++; } if(ck>r){ for(j=0;j<ck;j++)s.pop_back(); for(j=0;j<ck;j++){ s+='0'; if(!make_test(s)){ s.pop_back(); break; } } break; } } while(s.size()<n){ string t1 = "0"+s; if(make_test(t1))s = t1; else s = "1"+s; } return s; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:43:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |     while(s.size()<n){
      |           ~~~~~~~~^~
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...