Submission #932974

#TimeUsernameProblemLanguageResultExecution timeMemory
932974skyvn97Martian DNA (IOI16_dna)C++14
11 / 100
25 ms600 KiB
#ifndef SKY #include "dna.h" #endif // SKY #include <bits/stdc++.h> using namespace std; #ifdef SKY string analyse(int, int); struct Jury { static const int QUERY_LIMIT = 256; string s; int queryCount; void init(void) { int len = rand() % 10 + 1; s.clear(); for (int i = 0; i < len; i++) s.push_back(rand() % 2 ? '0' : '1'); queryCount = 0; } bool make_test(const string &p) { assert(++queryCount <= QUERY_LIMIT); if (p.size() > s.size()) return false; for (int i = 0; i <= s.size() - p.size(); i++) { bool ok = true; for (int j = 0; j < p.size(); j++) if (s[i + j] != p[j]) { ok = false; break; } if (ok) return true; } return false; } void process(void) { string r = analyse(s.size(), QUERY_LIMIT); assert(r == s); if (r != s) printf("Expected %s, received %s\n", s.c_str(), r.c_str()); else printf("ACCEPTED after %d queries\n", queryCount); } } jury; bool make_test(string p) { return jury.make_test(p); } #endif // SKY std::string analyse(int n, int t) { if (!make_test("1")) return string(n, '0'); string res = "1"; while ((int)res.size() < n) { if (make_test(res + "0")) res += "0"; else if (make_test(res + "1")) res += "1"; else if (make_test("0" + res)) res = "0" + res; else res = "1" + res; } return res; } #ifdef SKY int main(void) { for (int i = 0; i < 1000; i++) { jury.init(); jury.process(); } return 0; } #endif // SKY

Compilation message (stderr)

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...