Submission #1061206

#TimeUsernameProblemLanguageResultExecution timeMemory
1061206boyliguanhanMartian DNA (IOI16_dna)C++17
100 / 100
6 ms520 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(2893478); int bad_streak; string analyse(int n, int t) { string str="1"; while(1){ char c='0'+rng()%2; char oth=(c=='0'?'1':'0'); if(make_test(str+c)) str+=c,bad_streak=0; else str+=oth, bad_streak++; if(bad_streak==18){ if(make_test(str))continue; int l=str.size()-18,r=str.size()-1,res=str.size()-1; while(l<=r){ int mid=l+r>>1; if(make_test(str.substr(0,mid))) l=mid+1; else res=mid,r=mid-1; } str.erase(str.begin()+res-1,str.end()); break; } } while(str.size()<n){ char c='0'+rng()%2; char oth=(c=='0'?'1':'0'); if(make_test(c+str)) str=c+str; else str=oth+str; } return str; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:19:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |                 int mid=l+r>>1;
      |                         ~^~
dna.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     while(str.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...