Submission #800959

#TimeUsernameProblemLanguageResultExecution timeMemory
800959LIFMartian DNA (IOI16_dna)C++14
100 / 100
9 ms376 KiB
#include "dna.h" #include<bits/stdc++.h> #include <cstdlib> using namespace std; std::string analyse(int n, int t) { int l = 1; int r = n; int len = 0; while(l<=r) { int mid = (l+r)>>1; string temp; for(int i=1;i<=mid;i++)temp += "0"; if(make_test(temp) == true) { l = mid+1; len = mid; } else r = mid-1; } string ans; for(int i=1;i<=len;i++)ans += "0"; int now = 0; while(now <= len && ans.size() < n) { ans += "1"; if(make_test(ans) == true) { now = 0; } else { now++; ans.erase(ans.size()-1); ans += "0"; } } while(now--)ans.erase(ans.size()-1); while(make_test(ans + "0"))ans += "0"; while(ans.size() < n) { ans = "1" + ans; if(make_test(ans) == false) { ans.erase(0,1); ans = "0" + ans; } //cout<<ans<<endl; } return ans; }

Compilation message (stderr)

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