Submission #990468

#TimeUsernameProblemLanguageResultExecution timeMemory
990468aaaaaarrozMartian DNA (IOI16_dna)C++17
100 / 100
6 ms604 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; string analyse(int n, int t) { string ans = ""; int lo = 0, hi = n; while (lo < hi) { int mid = (lo + hi + 1) >> 1; string cur = ""; for (int i = 0; i < mid; ++i) cur += '0'; if (make_test(cur)) lo = mid; else hi = mid - 1; } for (int i = 0; i < lo; ++i) ans += '0'; int cnt = 0; while (ans.size() < n && cnt <= lo) { if (make_test(ans + "1")) { ans += "1"; cnt = 0; } else { ans += "0"; ++cnt; } } for (int i = 0; i < cnt; ++i) ans.pop_back(); while (make_test(ans + "0")) ans += '0'; if (ans.size() < n) ans = "1" + ans; 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:17:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |      while (ans.size() < n && cnt <= lo) {
      |             ~~~~~~~~~~~^~~
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 |      if (ans.size() < n) ans = "1" + ans;
      |          ~~~~~~~~~~~^~~
dna.cpp:29:24: 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 (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...