Submission #980602

#TimeUsernameProblemLanguageResultExecution timeMemory
980602NoMercyMartian DNA (IOI16_dna)C++17
100 / 100
10 ms604 KiB
#include "dna.h" #include <cstdlib> #include <bits/stdc++.h> using namespace std; string analyse(int n, int t) { string res; int lo = 1, hi = n, best = 0; while (lo <= hi) { int mid = (lo + hi) / 2; string tmp = res; for (int i = 0;i < mid;i ++) { tmp += '0'; } if (make_test(tmp) == true) { lo = mid + 1; best = mid; } else { hi = mid - 1; } } for (int i = 0;i < best;i ++) { res += '0'; } int cnt = 0 , sz = best; while (res.size() < n && cnt <= sz) { if (make_test(res + '1') == true) { cnt = 0; res += '1'; } else { cnt ++; res += '0'; } } lo = 1, hi = cnt, best = 0; while (cnt --) { res.pop_back(); } while (lo <= hi) { int mid = (lo + hi) / 2; string tmp = res; for (int i = 0;i < mid;i ++) { tmp += '0'; } if (make_test(tmp) == true) { lo = mid + 1; best = mid; } else { hi = mid - 1; } } for (int i = 0;i < best;i ++) { res += '0'; } cnt = 0; while (res.size() < n && cnt <= sz) { if (make_test('1' + res) == true) { cnt = 0; res = '1' + res; } else { cnt ++; res = '0' + res; } } lo = 1, hi = cnt, best = 0; reverse(res.begin() , res.end()); while (cnt --) { res.pop_back(); } reverse(res.begin() , res.end()); while (lo <= hi) { int mid = (lo + hi) / 2; string tmp = res; for (int i = 0;i < mid;i ++) { tmp = '0' + tmp; } if (make_test(tmp) == true) { lo = mid + 1; best = mid; } else { hi = mid - 1; } } for (int i = 0;i < best;i ++) { res = '0' + res; } return res; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:29:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while (res.size() < n && cnt <= sz) {
      |            ~~~~~~~~~~~^~~
dna.cpp:59:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |     while (res.size() < n && cnt <= sz) {
      |            ~~~~~~~~~~~^~~
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...