Submission #831851

#TimeUsernameProblemLanguageResultExecution timeMemory
831851KemalKMartian DNA (IOI16_dna)C++17
0 / 100
8 ms388 KiB
#include "dna.h" #include <bits/stdc++.h> #include <cstdlib> using namespace std; std::string analyse(int n, int t) { string ans = ""; int l = 0, r = n; while (l < r){ int mid = (r + l + 1)>>1; string cur = ""; for (int i = 0; i < mid; i++){ cur += "0"; } if (make_test(cur)){ l = mid; } else{ r = mid - 1; } } int k = 0; for (int i = 0; i < l; i++){ ans += "0"; } while(ans.size() < n and k <= l){ if (make_test(ans + "1")){ ans += "1"; k = 0; } else{ k++; ans += "0"; } } for (int i = 0; i < l; i++){ ans.pop_back(); } while(make_test(ans + "0")){ ans += "0"; } while(ans.size() < n){ if (make_test(ans + "1")){ ans += "1"; } else{ ans += "0"; } } return ans; }

Compilation message (stderr)

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while(ans.size() < n and k <= l){
      |           ~~~~~~~~~~~^~~
dna.cpp:42:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     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...