Submission #412228

#TimeUsernameProblemLanguageResultExecution timeMemory
412228nxteruMartian DNA (IOI16_dna)C++14
100 / 100
13 ms408 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string analyse(int n, int t) { string ans; bool st=false; int m=t-(n-ans.size()); while(n-ans.size()>=m-1){ if((m-2)*(m-1)/2>=n-ans.size()){ st=true; break; } m--; string p; for(int i=0;i<m-1;i++)p+='0'; if(!make_test(p))break; else{ m+=(p.size()-ans.size()); ans=p; } } string y; if(st)m--; while(ans.size()<n){ if(y.size()==m-1){ if(st){ if(make_test(ans+y)){ m--; ans+=y; y=""; continue; } } for(int i=0;i<m-2;i++){ if(!make_test(ans+'0'))break; ans+='0'; } break; }else{ if(make_test(ans+y+'1')){ ans=ans+y+'1'; y=""; }else y+='0'; } } while(ans.size()<n){ if(make_test('1'+ans))ans='1'+ans; else ans='0'+ans; } return ans; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:9:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     while(n-ans.size()>=m-1){
      |           ~~~~~~~~~~~~^~~~~
dna.cpp:10:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         if((m-2)*(m-1)/2>=n-ans.size()){
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~
dna.cpp:25:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while(ans.size()<n){
      |           ~~~~~~~~~~^~
dna.cpp:26:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         if(y.size()==m-1){
      |            ~~~~~~~~^~~~~
dna.cpp:47:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     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...