Submission #497290

#TimeUsernameProblemLanguageResultExecution timeMemory
497290MilosMilutinovicMartian DNA (IOI16_dna)C++14
100 / 100
12 ms396 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; bool make_test(string s); string analyse(int n, int t){ if(!make_test("0"))return string(n, '1'); string ans = ""; int l = 1, r = n, len; while(l <= r){ int mid = (l+r)/2; if(make_test(string(mid, '0'))){ len = mid; l = mid + 1; } else r = mid - 1; } ans = string(len, '0'); int cnt = 0; while(ans.size()<n && cnt<=len){ if(make_test(ans + '1')){ ans += '1'; cnt = 0; } else { ans += '0'; cnt++; } } l = 1, r = ans.size(); string ns; while(l <= r){ int mid = (l+r)/2; string q = ""; for(int i=0; i<mid; i++)q += ans[i]; if(make_test(q)){ l = mid + 1; ns = q; } else r = mid - 1; } ans = ns; 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:22:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |  while(ans.size()<n && cnt<=len){
      |        ~~~~~~~~~~^~
dna.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |  while(ans.size()<n){
      |        ~~~~~~~~~~^~
dna.cpp:22:21: warning: 'len' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  while(ans.size()<n && cnt<=len){
      |        ~~~~~~~~~~~~~^~~~~~~~~~~
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...