Submission #242703

# Submission time Handle Problem Language Result Execution time Memory
242703 2020-06-29T04:09:01 Z HynDuf Martian DNA (IOI16_dna) C++14
100 / 100
20 ms 384 KB
#include <bits/stdc++.h>

#include <dna.h>
#define task "D"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
/*
string S = "1";
bool make_test(string P)
{
    return (S.find(P) != string::npos);
}
*/
string analyse(int n, int t)
{
    int l = 1, r = n, len = 0;
    while (l <= r)
    {
        int m = (l + r) >> 1;
        string q = "";
        rep(i, 1, m) q += '0';
        if (make_test(q)) l = m + 1, len = m;
        else r = m - 1;
    }
    string tem = "";
    rep(i, 1, len) tem += '0';
    int conse0 = len;
    while (conse0 <= len)
    {
        string te = tem + '1';
        if (make_test(te)) tem += '1', conse0 = 0;
        else tem += '0', conse0++;
    }
    l = 1, r = len;
    string ans = tem.substr(0, SZ(tem) - len - 1);
    while (l <= r)
    {
        int m = (l + r) >> 1;
        string te = tem.substr(0, SZ(tem) - (len + 1 - m));
        if (make_test(te)) l = m + 1, ans = te;
        else r = m - 1;
    }
    int left = n - SZ(ans);
    rep(i, 1, left)
    {
        string te = '1' + ans;
        if (make_test(te)) ans = te;
        else ans = '0' + ans;
    }
    return ans;
}
/*
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cout << analyse(SZ(S), 2 * SZ(S));
    return 0;
}
*/

Compilation message

grader.cpp: In function 'bool make_test(std::__cxx11::string)':
grader.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < p.size(); i++) {
                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i <= ss.size(); i++) {
                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pr[i] == p.size()) {
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 4 ms 256 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 256 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 6 ms 256 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 5 ms 256 KB Output is correct
32 Correct 5 ms 256 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 15 ms 384 KB Output is correct
23 Correct 15 ms 384 KB Output is correct
24 Correct 15 ms 384 KB Output is correct
25 Correct 20 ms 384 KB Output is correct
26 Correct 18 ms 384 KB Output is correct
27 Correct 11 ms 384 KB Output is correct
28 Correct 11 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 13 ms 384 KB Output is correct
31 Correct 11 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 15 ms 384 KB Output is correct
34 Correct 14 ms 384 KB Output is correct
35 Correct 13 ms 384 KB Output is correct
36 Correct 13 ms 384 KB Output is correct
37 Correct 12 ms 384 KB Output is correct
38 Correct 15 ms 384 KB Output is correct
39 Correct 11 ms 384 KB Output is correct