Submission #882289

#TimeUsernameProblemLanguageResultExecution timeMemory
882289pirhosigMartian DNA (IOI16_dna)C++17
36 / 100
1100 ms1084 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string analyse(int n, int t) { string res; if (n < 500) { bool forward = true; for (int i = 0; i < n; ++i) { if (forward) { if (make_test(res + '0')) res += '0'; else if (make_test(res + '1')) res += '1'; else forward = false; } if (!forward) { res.insert(0, 1, '0'); if (!make_test(res)) res[0] = '1'; } } } else { int len = 0; int val = 0; while (val < n) { if (rand() % 2) { res.append("0"); if (make_test(res)) len = val; else res.back() = '1'; } else { res.append("1"); if (make_test(res)) len = val; else res.back() = '0'; } if (val - len == 11) { bool full = true; while (len < val) { int mid = (len + val + 1) / 2; if (make_test(res.substr(0, mid))) len = mid; else { for (int i = 0; i <= val - mid; ++i) res.pop_back(); val = mid - 1; goto end; } } } } end: while (len < val) { int mid = (len + val + 1) / 2; if (make_test(res.substr(0, mid))) len = mid; else { for (int i = 0; i <= val - mid; ++i) res.pop_back(); val = mid - 1; } } while (len < n) { res.insert(0, 1, '0'); if (!make_test(res)) res[0] = '1'; len++; } } return res; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:44:22: warning: unused variable 'full' [-Wunused-variable]
   44 |                 bool full = true;
      |                      ^~~~
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...