Submission #965569

#TimeUsernameProblemLanguageResultExecution timeMemory
965569AdamGSMartian DNA (IOI16_dna)C++17
100 / 100
9 ms600 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int los(int a, int b) { return rng()%(b-a+1)+a; } string analyse(int n, int t) { string ans=""; int akt=0; while(true) { char a=los('0', '1'); ++akt; if(make_test(ans+a)) { ans+=a; akt=0; } else { if(a=='0') ans+="1"; else ans+="0"; } if(akt<16) continue; if(make_test(ans)) { akt=0; continue; } int po=1, ko=16; while(po<ko) { int sr=(po+ko)/2; string s=ans; rep(i, sr) s.pop_back(); if(make_test(s)) ko=sr; else po=sr+1; } rep(i, po) ans.pop_back(); break; } while(ans.size()<n) { if(make_test("0"+ans)) ans="0"+ans; else ans="1"+ans; } return ans; }

Compilation message (stderr)

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