답안 #882289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882289 2023-12-03T01:07:13 Z pirhosig Martian DNA (IOI16_dna) C++17
36 / 100
1000 ms 1084 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;



string analyse(int n, int t)
{
    string res;
    if (n < 500)
    {
        bool forward = true;
        for (int i = 0; i < n; ++i)
        {
            if (forward)
            {
                if (make_test(res + '0')) res += '0';
                else if (make_test(res + '1')) res += '1';
                else forward = false;
            }
            if (!forward)
            {
                res.insert(0, 1, '0');
                if (!make_test(res)) res[0] = '1';
            }
        }
    }
    else
    {
        int len = 0;
        int val = 0;
        while (val < n) {
            if (rand() % 2) {
                res.append("0");
                if (make_test(res)) len = val;
                else res.back() = '1';
            }
            else {
                res.append("1");
                if (make_test(res)) len = val;
                else res.back() = '0';
            }
            if (val - len == 11) {
                bool full = true;
                while (len < val) {
                    int mid = (len + val + 1) / 2;
                    if (make_test(res.substr(0, mid))) len = mid;
                    else {
                        for (int i = 0; i <= val - mid; ++i) res.pop_back();
                        val = mid - 1;
                        goto end;
                    }
                }
            }
        }
        end:
        while (len < val) {
            int mid = (len + val + 1) / 2;
            if (make_test(res.substr(0, mid))) len = mid;
            else {
                for (int i = 0; i <= val - mid; ++i) res.pop_back();
                val = mid - 1;
            }
        }
        while (len < n) {
            res.insert(0, 1, '0');
            if (!make_test(res)) res[0] = '1';
            len++;
        }
    }

    return res;
}               

Compilation message

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:44:22: warning: unused variable 'full' [-Wunused-variable]
   44 |                 bool full = true;
      |                      ^~~~
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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 436 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 432 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 496 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 420 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Execution timed out 1071 ms 628 KB Time limit exceeded
23 Execution timed out 1065 ms 520 KB Time limit exceeded
24 Execution timed out 1062 ms 868 KB Time limit exceeded
25 Execution timed out 1016 ms 868 KB Time limit exceeded
26 Execution timed out 1035 ms 888 KB Time limit exceeded
27 Execution timed out 1028 ms 852 KB Time limit exceeded
28 Execution timed out 1022 ms 620 KB Time limit exceeded
29 Execution timed out 1022 ms 580 KB Time limit exceeded
30 Execution timed out 1010 ms 592 KB Time limit exceeded
31 Execution timed out 1066 ms 528 KB Time limit exceeded
32 Execution timed out 1041 ms 784 KB Time limit exceeded
33 Execution timed out 1041 ms 828 KB Time limit exceeded
34 Execution timed out 1048 ms 864 KB Time limit exceeded
35 Execution timed out 1100 ms 828 KB Time limit exceeded
36 Execution timed out 1036 ms 620 KB Time limit exceeded
37 Execution timed out 1074 ms 660 KB Time limit exceeded
38 Execution timed out 1026 ms 780 KB Time limit exceeded
39 Execution timed out 1037 ms 1084 KB Time limit exceeded