답안 #595769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595769 2022-07-14T06:21:13 Z jophyyjh Martian DNA (IOI16_dna) C++14
36 / 100
13 ms 456 KB
/**
 * OK, so we have a binary str of len n. Each time we're allowed to give a str and
 * whether the str is a substr of the original binary str is returned. The task is
 * to determine the entire str under a certain num of interactions.
 * 
 * Well it looks to me that the num of steps shall be O(n). Well, i think i've got
 * a solution by extending the current str on either side. 2n steps is now the
 * maximum.
 * 
 * We want to further lower the num of interactions. Can we directly determine the
 * first char? Well i guess the goal is to find the suffix (or equivalently the
 * prefix). In the algo above, we extend our str on the right side until it can 
 * no longer be extended; after this, we can just extend it on the left side,
 * without fearing that a "true" response corresponds to a substr which is not a
 * suffix (shifted pos). In other words, we wish to find a substr such that:
 *          make_test((substr)0), make_test((substr)1) are all false.
 * 
 * Number of steps: 2n
 * Implementation 1
*/

#include <bits/stdc++.h>
#include "dna.h"


std::string analyse(int n, int T) {
    std::string current = "";
    for (;;) {
        bool one = make_test(current + "1");
        if (one) {
            current.push_back('1');
            continue;
        }
        bool zero = make_test(current + "0");
        if (zero) {
            current.push_back('0');
            continue;
        }
        // can't append any char (at the back)
        break;
    }
    assert(int(current.size()) <= n);
    while (int(current.size()) < n) {
        if (make_test("0" + current))
            current.insert(0, 1, '0');
        else
            current.insert(0, 1, '1');
    }
    return current;
}

Compilation message

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()) {
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 296 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Incorrect 11 ms 376 KB Too many tests
23 Incorrect 12 ms 340 KB Too many tests
24 Incorrect 12 ms 292 KB Too many tests
25 Incorrect 13 ms 304 KB Too many tests
26 Incorrect 11 ms 384 KB Too many tests
27 Incorrect 8 ms 340 KB Too many tests
28 Incorrect 8 ms 340 KB Too many tests
29 Incorrect 13 ms 340 KB Too many tests
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Incorrect 12 ms 384 KB Too many tests
33 Incorrect 8 ms 340 KB Too many tests
34 Incorrect 11 ms 384 KB Too many tests
35 Incorrect 9 ms 340 KB Too many tests
36 Incorrect 10 ms 380 KB Too many tests
37 Incorrect 11 ms 340 KB Too many tests
38 Correct 9 ms 340 KB Output is correct
39 Incorrect 9 ms 384 KB Too many tests