Submission #776291

# Submission time Handle Problem Language Result Execution time Memory
776291 2023-07-07T14:52:11 Z marvinthang Copy and Paste 3 (JOI22_copypaste3) C++17
100 / 100
653 ms 49860 KB
/*************************************
*    author: marvinthang             *
*    created: 07.07.2023 21:33:29    *
*************************************/

#include <bits/stdc++.h>

using namespace std;

#define                  fi  first
#define                  se  second
#define                left  ___left
#define               right  ___right
#define                TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define             MASK(i)  (1LL << (i))
#define           BIT(x, i)  ((x) >> (i) & 1)
#define  __builtin_popcount  __builtin_popcountll
#define              ALL(v)  (v).begin(), (v).end()
#define           REP(i, n)  for (int i = 0, _n = (n); i < _n; ++i)
#define          REPD(i, n)  for (int i = (n); i--; )
#define        FOR(i, a, b)  for (int i = (a), _b = (b); i < _b; ++i) 
#define       FORD(i, b, a)  for (int i = (b), _a = (a); --i >= _a; ) 
#define       FORE(i, a, b)  for (int i = (a), _b = (b); i <= _b; ++i) 
#define      FORDE(i, b, a)  for (int i = (b), _a = (a); i >= _a; --i) 
#define        scan_op(...)  istream & operator >> (istream &in, __VA_ARGS__ &u)
#define       print_op(...)  ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#ifdef LOCAL
    #include "debug.h"
#else
    #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
    #define DB(...) 23
    #define db(...) 23
    #define debug(...) 23
#endif

template <class U, class V> scan_op(pair <U, V>)  { return in >> u.first >> u.second; }
template <class T> scan_op(vector <T>)  { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; }
template <class U, class V> print_op(pair <U, V>)  { return out << '(' << u.first << ", " << u.second << ')'; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")";  else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; }
template <class A, class B> bool minimize(A &a, B b)  { if (a > b) { a = b; return true; } return false; }
template <class A, class B> bool maximize(A &a, B b)  { if (a < b) { a = b; return true; } return false; }

namespace HASHING {

    const int NMOD = 2;
    const int MOD[] = {(int) 1e9 + 7, (int) 1e9 + 2277, (int) 1e9 + 5277, 
                            (int) 1e9 + 8277, (int) 1e9 + 9277};
    const int BASE = 31; // 311
    const int capital = 'a';
    const int MAX_SIZE = 2505 + 6;

    int pw[NMOD][MAX_SIZE];

    void prepareHashing(void) {
        for (int j = 0; j < NMOD; ++j) {
            pw[j][0] = 1;
            for (int i = 1; i < MAX_SIZE; ++i)
                pw[j][i] = 1LL * pw[j][i - 1] * BASE % MOD[j];
        }
    }

    struct Value {

            int val[NMOD];
        
            Value(int x = 0) { for (int i = 0; i < NMOD; ++i) val[i] = x; }

            Value(char c, int pos) {
                for (int i = 0; i < NMOD; ++i) 
                    val[i] = 1LL * c * pw[i][pos] % MOD[i];
            }

            Value shift(int step) const {
                Value res;
                for (int i = 0; i < NMOD; ++i)
                    res.val[i] = 1LL * val[i] * pw[i][step] % MOD[i];
                return res;
            }

            Value operator + (const Value &other) const {
                Value res;
                for (int i = 0; i < NMOD; ++i) {
                    res.val[i] = val[i] + other.val[i];
                    if (res.val[i] >= MOD[i]) res.val[i] -= MOD[i];
                }
                return res;
            }

            Value operator - (const Value &other) const {
                Value res;
                for (int i = 0; i < NMOD; ++i) {
                    res.val[i] = val[i] - other.val[i];
                    if (res.val[i] < 0) res.val[i] += MOD[i];
                }
                return res;
            }

            bool operator < (const Value& other) const { 
                for (int i = 0; i < NMOD; ++i)
                    if (val[i] != other.val[i]) return val[i] < other.val[i];
                return false;
            }

            bool operator == (const Value& other) const {
                for (int i = 0; i < NMOD; ++i)
                    if (val[i] != other.val[i]) return false;
                return true;
            }
        
            bool operator != (const Value& other) const {
                for (int i = 0; i < NMOD; ++i) 
                    if (val[i] != other.val[i]) return true;
                return false;
            }
    
    };

    struct Hash {

        string S;
        int len;
        Value *code, *rev_code;

        void Init_Hash(bool palin = false) {
            len = S.size();
            S = ' ' + S;
            code = new Value[len + 1];
            code[0] = 0;
            if (palin) {
                rev_code = new Value[len + 1];
                rev_code[0] = 0;
            }
            for (int i = 1; i <= len; ++i) {
                code[i] = code[i - 1] + Value(S[i] - capital + 1, i);
                if (palin) rev_code[i] = rev_code[i - 1] + Value(S[len - i + 1] - capital + 1, i);
            }
        }

        Hash() {}

        Hash(string s, bool palin = false) {
            S = s;
            Init_Hash(palin);
        }

        int getHash(int l, int r, int mod) const {
            assert(l <= r && l > 0 && r <= len);
            int res = code[r].val[mod] - code[l - 1].val[mod];
            if (res < 0) res += MOD[mod];
            res = 1LL * res * pw[mod][MAX_SIZE - l] % MOD[mod];
            return res;
        }

        Value getHash(int l, int r) const {
            assert(l <= r && l > 0 && r <= len);
            return (code[r] - code[l - 1]).shift(MAX_SIZE - l);
        }

        Value getRevHash(int l, int r) {
            assert(l <= r && l > 0 && r <= len);
            return (rev_code[r] - rev_code[l - 1]).shift(MAX_SIZE - l);
        }

        bool isPalin(int l, int r) {
            return getHash(l, r) == getRevHash(len - r + 1, len - l + 1);
        }

        Value getHash(void) const {
            return getHash(1, len);
        }

        bool operator == (Hash& other) const {
            return code[len] == other.code[other.len];
        }

        bool operator < (Hash& other) const{    
            return code[len] < other.code[other.len];
        }

        bool operator > (Hash& other) const{
            return !(code[len] < other.code[other.len] || code[len] == other.code[other.len]);
        }

        bool cmpSubstr(int l, int r, int u, int v) {
            assert(l <= r && u <= v); assert(l > 0 && u > 0); assert(r <= len && v <= len);
            int len = min(r - l + 1, v - u + 1);
            int max_same = 0;
            int Min = 1, Max = len;
            while (Min <= Max) {
                int mid = Min + Max >> 1;
                Value F1 = getHash(l, l + mid - 1);
                Value F2 = getHash(u, u + mid - 1);
                if (F1 == F2) {
                    max_same = mid;
                    Min = mid + 1;
                } else Max = mid - 1;
            }
            if (max_same == len) return r - l < v - u;
            return S[l + max_same] < S[u + max_same];
        }

    };

    bool cmpStr(Hash a, Hash b) {
        int len = min(a.len, b.len);
        int max_same = 0;
        int l = 1, r = len - 1;
        while (l <= r) {
            int mid = l + r >> 1;
            Value F1 = a.getHash(1, mid);
            Value F2 = b.getHash(1, mid);
            if (F1 == F2) {
                max_same = mid;
                l = mid + 1;
            } else r = mid - 1;
        }
        if (max_same == len) return a.len < b.len;
        return a.S[max_same + 1] < b.S[max_same + 1];
    }

}

using namespace HASHING;

// end of template

const int MAX = 2505;

int N, A, B, C;
string S;
Hash h;

void init(void) {
	prepareHashing();
	cin >> N >> S >> A >> B >> C;
	h = Hash(S);
}

long long dp[MAX][MAX];

void process(void) {
	memset(dp, 0x3f, sizeof(dp));
	FORE(i, 1, N) dp[i][i] = A;
	FORE(len, 1, N) {
		map <Value, vector <int>> v;
		FORE(l, 1, N - len + 1) {
			int r = l + len - 1;
			minimize(dp[l][r], min(dp[l][r - 1], dp[l + 1][r]) + A);
			v[h.getHash(l, r)].push_back(l);
		}
		vector <int> nxt(N + 1);
		for (auto [love, v]: v) {
			int r = 0;
			for (int l: v) {
				while (r < v.size() && v[r] < l + len) ++r;
				nxt[l] = r < v.size() ? v[r] : 0;
			}
			for (int l: v) {
				int pos = l;
				int cnt = 0;
				while (pos) {
					++cnt;
					r = pos + len - 1; pos = nxt[pos];
					minimize(dp[l][r], dp[l][l + len - 1] + B + 1LL * C * cnt + 1LL * A * (r - l + 1 - cnt * len));
				}
			}
		}
	}
	cout << dp[1][N] << '\n';
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr);
	file("copypaste3");
	init();
	process();
	cerr << "Time elapsed: " << TIME << " s.\n";
	return (0^0);
}

Compilation message

copypaste3.cpp: In member function 'bool HASHING::Hash::cmpSubstr(int, int, int, int)':
copypaste3.cpp:192:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  192 |                 int mid = Min + Max >> 1;
      |                           ~~~~^~~~~
copypaste3.cpp: In function 'bool HASHING::cmpStr(HASHING::Hash, HASHING::Hash)':
copypaste3.cpp:211:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  211 |             int mid = l + r >> 1;
      |                       ~~^~~
copypaste3.cpp: In function 'void process()':
copypaste3.cpp:257:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  257 |     while (r < v.size() && v[r] < l + len) ++r;
      |            ~~^~~~~~~~~~
copypaste3.cpp:258:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  258 |     nxt[l] = r < v.size() ? v[r] : 0;
      |              ~~^~~~~~~~~~
copypaste3.cpp: In function 'int main()':
copypaste3.cpp:30:61: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
copypaste3.cpp:276:2: note: in expansion of macro 'file'
  276 |  file("copypaste3");
      |  ^~~~
copypaste3.cpp:30:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
copypaste3.cpp:276:2: note: in expansion of macro 'file'
  276 |  file("copypaste3");
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 16 ms 49364 KB Output is correct
3 Correct 17 ms 49440 KB Output is correct
4 Correct 16 ms 49392 KB Output is correct
5 Correct 16 ms 49440 KB Output is correct
6 Correct 17 ms 49440 KB Output is correct
7 Correct 17 ms 49432 KB Output is correct
8 Correct 17 ms 49364 KB Output is correct
9 Correct 18 ms 49364 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 17 ms 49384 KB Output is correct
3 Correct 121 ms 49492 KB Output is correct
4 Correct 140 ms 49484 KB Output is correct
5 Correct 184 ms 49500 KB Output is correct
6 Correct 219 ms 49500 KB Output is correct
7 Correct 261 ms 49492 KB Output is correct
8 Correct 273 ms 49508 KB Output is correct
9 Correct 262 ms 49520 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
11 Correct 17 ms 49364 KB Output is correct
12 Correct 18 ms 49432 KB Output is correct
13 Correct 18 ms 49364 KB Output is correct
14 Correct 18 ms 49364 KB Output is correct
15 Correct 17 ms 49352 KB Output is correct
16 Correct 17 ms 49376 KB Output is correct
17 Correct 18 ms 49364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 16 ms 49364 KB Output is correct
3 Correct 17 ms 49440 KB Output is correct
4 Correct 16 ms 49392 KB Output is correct
5 Correct 16 ms 49440 KB Output is correct
6 Correct 17 ms 49440 KB Output is correct
7 Correct 17 ms 49432 KB Output is correct
8 Correct 17 ms 49364 KB Output is correct
9 Correct 18 ms 49364 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
11 Correct 17 ms 49364 KB Output is correct
12 Correct 16 ms 49364 KB Output is correct
13 Correct 16 ms 49444 KB Output is correct
14 Correct 17 ms 49420 KB Output is correct
15 Correct 17 ms 49364 KB Output is correct
16 Correct 18 ms 49408 KB Output is correct
17 Correct 17 ms 49364 KB Output is correct
18 Correct 18 ms 49412 KB Output is correct
19 Correct 16 ms 49364 KB Output is correct
20 Correct 17 ms 49464 KB Output is correct
21 Correct 17 ms 49408 KB Output is correct
22 Correct 17 ms 49412 KB Output is correct
23 Correct 18 ms 49372 KB Output is correct
24 Correct 18 ms 49412 KB Output is correct
25 Correct 17 ms 49364 KB Output is correct
26 Correct 17 ms 49448 KB Output is correct
27 Correct 18 ms 49440 KB Output is correct
28 Correct 17 ms 49364 KB Output is correct
29 Correct 20 ms 49368 KB Output is correct
30 Correct 22 ms 49464 KB Output is correct
31 Correct 20 ms 49396 KB Output is correct
32 Correct 17 ms 49364 KB Output is correct
33 Correct 18 ms 49364 KB Output is correct
34 Correct 18 ms 49376 KB Output is correct
35 Correct 19 ms 49368 KB Output is correct
36 Correct 18 ms 49416 KB Output is correct
37 Correct 18 ms 49440 KB Output is correct
38 Correct 17 ms 49364 KB Output is correct
39 Correct 17 ms 49448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 16 ms 49364 KB Output is correct
3 Correct 17 ms 49440 KB Output is correct
4 Correct 16 ms 49392 KB Output is correct
5 Correct 16 ms 49440 KB Output is correct
6 Correct 17 ms 49440 KB Output is correct
7 Correct 17 ms 49432 KB Output is correct
8 Correct 17 ms 49364 KB Output is correct
9 Correct 18 ms 49364 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
11 Correct 17 ms 49364 KB Output is correct
12 Correct 16 ms 49364 KB Output is correct
13 Correct 16 ms 49444 KB Output is correct
14 Correct 17 ms 49420 KB Output is correct
15 Correct 17 ms 49364 KB Output is correct
16 Correct 18 ms 49408 KB Output is correct
17 Correct 17 ms 49364 KB Output is correct
18 Correct 18 ms 49412 KB Output is correct
19 Correct 16 ms 49364 KB Output is correct
20 Correct 17 ms 49464 KB Output is correct
21 Correct 17 ms 49408 KB Output is correct
22 Correct 17 ms 49412 KB Output is correct
23 Correct 18 ms 49372 KB Output is correct
24 Correct 18 ms 49412 KB Output is correct
25 Correct 17 ms 49364 KB Output is correct
26 Correct 17 ms 49448 KB Output is correct
27 Correct 18 ms 49440 KB Output is correct
28 Correct 17 ms 49364 KB Output is correct
29 Correct 20 ms 49368 KB Output is correct
30 Correct 22 ms 49464 KB Output is correct
31 Correct 20 ms 49396 KB Output is correct
32 Correct 17 ms 49364 KB Output is correct
33 Correct 18 ms 49364 KB Output is correct
34 Correct 18 ms 49376 KB Output is correct
35 Correct 19 ms 49368 KB Output is correct
36 Correct 18 ms 49416 KB Output is correct
37 Correct 18 ms 49440 KB Output is correct
38 Correct 17 ms 49364 KB Output is correct
39 Correct 17 ms 49448 KB Output is correct
40 Correct 18 ms 49364 KB Output is correct
41 Correct 18 ms 49364 KB Output is correct
42 Correct 20 ms 49432 KB Output is correct
43 Correct 20 ms 49352 KB Output is correct
44 Correct 20 ms 49364 KB Output is correct
45 Correct 20 ms 49364 KB Output is correct
46 Correct 21 ms 49364 KB Output is correct
47 Correct 19 ms 49464 KB Output is correct
48 Correct 20 ms 49364 KB Output is correct
49 Correct 20 ms 49408 KB Output is correct
50 Correct 20 ms 49472 KB Output is correct
51 Correct 20 ms 49392 KB Output is correct
52 Correct 19 ms 49456 KB Output is correct
53 Correct 21 ms 49364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 16 ms 49364 KB Output is correct
3 Correct 17 ms 49440 KB Output is correct
4 Correct 16 ms 49392 KB Output is correct
5 Correct 16 ms 49440 KB Output is correct
6 Correct 17 ms 49440 KB Output is correct
7 Correct 17 ms 49432 KB Output is correct
8 Correct 17 ms 49364 KB Output is correct
9 Correct 18 ms 49364 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
11 Correct 17 ms 49364 KB Output is correct
12 Correct 16 ms 49364 KB Output is correct
13 Correct 16 ms 49444 KB Output is correct
14 Correct 17 ms 49420 KB Output is correct
15 Correct 17 ms 49364 KB Output is correct
16 Correct 18 ms 49408 KB Output is correct
17 Correct 17 ms 49364 KB Output is correct
18 Correct 18 ms 49412 KB Output is correct
19 Correct 16 ms 49364 KB Output is correct
20 Correct 17 ms 49464 KB Output is correct
21 Correct 17 ms 49408 KB Output is correct
22 Correct 17 ms 49412 KB Output is correct
23 Correct 18 ms 49372 KB Output is correct
24 Correct 18 ms 49412 KB Output is correct
25 Correct 17 ms 49364 KB Output is correct
26 Correct 17 ms 49448 KB Output is correct
27 Correct 18 ms 49440 KB Output is correct
28 Correct 17 ms 49364 KB Output is correct
29 Correct 20 ms 49368 KB Output is correct
30 Correct 22 ms 49464 KB Output is correct
31 Correct 20 ms 49396 KB Output is correct
32 Correct 17 ms 49364 KB Output is correct
33 Correct 18 ms 49364 KB Output is correct
34 Correct 18 ms 49376 KB Output is correct
35 Correct 19 ms 49368 KB Output is correct
36 Correct 18 ms 49416 KB Output is correct
37 Correct 18 ms 49440 KB Output is correct
38 Correct 17 ms 49364 KB Output is correct
39 Correct 17 ms 49448 KB Output is correct
40 Correct 18 ms 49364 KB Output is correct
41 Correct 18 ms 49364 KB Output is correct
42 Correct 20 ms 49432 KB Output is correct
43 Correct 20 ms 49352 KB Output is correct
44 Correct 20 ms 49364 KB Output is correct
45 Correct 20 ms 49364 KB Output is correct
46 Correct 21 ms 49364 KB Output is correct
47 Correct 19 ms 49464 KB Output is correct
48 Correct 20 ms 49364 KB Output is correct
49 Correct 20 ms 49408 KB Output is correct
50 Correct 20 ms 49472 KB Output is correct
51 Correct 20 ms 49392 KB Output is correct
52 Correct 19 ms 49456 KB Output is correct
53 Correct 21 ms 49364 KB Output is correct
54 Correct 32 ms 49492 KB Output is correct
55 Correct 33 ms 49464 KB Output is correct
56 Correct 103 ms 49580 KB Output is correct
57 Correct 102 ms 49576 KB Output is correct
58 Correct 115 ms 49492 KB Output is correct
59 Correct 101 ms 49572 KB Output is correct
60 Correct 102 ms 49488 KB Output is correct
61 Correct 79 ms 49388 KB Output is correct
62 Correct 34 ms 49436 KB Output is correct
63 Correct 92 ms 49524 KB Output is correct
64 Correct 93 ms 49524 KB Output is correct
65 Correct 80 ms 49504 KB Output is correct
66 Correct 80 ms 49444 KB Output is correct
67 Correct 102 ms 49576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 49364 KB Output is correct
2 Correct 16 ms 49364 KB Output is correct
3 Correct 17 ms 49440 KB Output is correct
4 Correct 16 ms 49392 KB Output is correct
5 Correct 16 ms 49440 KB Output is correct
6 Correct 17 ms 49440 KB Output is correct
7 Correct 17 ms 49432 KB Output is correct
8 Correct 17 ms 49364 KB Output is correct
9 Correct 18 ms 49364 KB Output is correct
10 Correct 17 ms 49364 KB Output is correct
11 Correct 17 ms 49364 KB Output is correct
12 Correct 17 ms 49384 KB Output is correct
13 Correct 121 ms 49492 KB Output is correct
14 Correct 140 ms 49484 KB Output is correct
15 Correct 184 ms 49500 KB Output is correct
16 Correct 219 ms 49500 KB Output is correct
17 Correct 261 ms 49492 KB Output is correct
18 Correct 273 ms 49508 KB Output is correct
19 Correct 262 ms 49520 KB Output is correct
20 Correct 17 ms 49364 KB Output is correct
21 Correct 17 ms 49364 KB Output is correct
22 Correct 18 ms 49432 KB Output is correct
23 Correct 18 ms 49364 KB Output is correct
24 Correct 18 ms 49364 KB Output is correct
25 Correct 17 ms 49352 KB Output is correct
26 Correct 17 ms 49376 KB Output is correct
27 Correct 18 ms 49364 KB Output is correct
28 Correct 17 ms 49364 KB Output is correct
29 Correct 16 ms 49364 KB Output is correct
30 Correct 16 ms 49444 KB Output is correct
31 Correct 17 ms 49420 KB Output is correct
32 Correct 17 ms 49364 KB Output is correct
33 Correct 18 ms 49408 KB Output is correct
34 Correct 17 ms 49364 KB Output is correct
35 Correct 18 ms 49412 KB Output is correct
36 Correct 16 ms 49364 KB Output is correct
37 Correct 17 ms 49464 KB Output is correct
38 Correct 17 ms 49408 KB Output is correct
39 Correct 17 ms 49412 KB Output is correct
40 Correct 18 ms 49372 KB Output is correct
41 Correct 18 ms 49412 KB Output is correct
42 Correct 17 ms 49364 KB Output is correct
43 Correct 17 ms 49448 KB Output is correct
44 Correct 18 ms 49440 KB Output is correct
45 Correct 17 ms 49364 KB Output is correct
46 Correct 20 ms 49368 KB Output is correct
47 Correct 22 ms 49464 KB Output is correct
48 Correct 20 ms 49396 KB Output is correct
49 Correct 17 ms 49364 KB Output is correct
50 Correct 18 ms 49364 KB Output is correct
51 Correct 18 ms 49376 KB Output is correct
52 Correct 19 ms 49368 KB Output is correct
53 Correct 18 ms 49416 KB Output is correct
54 Correct 18 ms 49440 KB Output is correct
55 Correct 17 ms 49364 KB Output is correct
56 Correct 17 ms 49448 KB Output is correct
57 Correct 18 ms 49364 KB Output is correct
58 Correct 18 ms 49364 KB Output is correct
59 Correct 20 ms 49432 KB Output is correct
60 Correct 20 ms 49352 KB Output is correct
61 Correct 20 ms 49364 KB Output is correct
62 Correct 20 ms 49364 KB Output is correct
63 Correct 21 ms 49364 KB Output is correct
64 Correct 19 ms 49464 KB Output is correct
65 Correct 20 ms 49364 KB Output is correct
66 Correct 20 ms 49408 KB Output is correct
67 Correct 20 ms 49472 KB Output is correct
68 Correct 20 ms 49392 KB Output is correct
69 Correct 19 ms 49456 KB Output is correct
70 Correct 21 ms 49364 KB Output is correct
71 Correct 32 ms 49492 KB Output is correct
72 Correct 33 ms 49464 KB Output is correct
73 Correct 103 ms 49580 KB Output is correct
74 Correct 102 ms 49576 KB Output is correct
75 Correct 115 ms 49492 KB Output is correct
76 Correct 101 ms 49572 KB Output is correct
77 Correct 102 ms 49488 KB Output is correct
78 Correct 79 ms 49388 KB Output is correct
79 Correct 34 ms 49436 KB Output is correct
80 Correct 92 ms 49524 KB Output is correct
81 Correct 93 ms 49524 KB Output is correct
82 Correct 80 ms 49504 KB Output is correct
83 Correct 80 ms 49444 KB Output is correct
84 Correct 102 ms 49576 KB Output is correct
85 Correct 254 ms 49660 KB Output is correct
86 Correct 653 ms 49784 KB Output is correct
87 Correct 646 ms 49768 KB Output is correct
88 Correct 623 ms 49772 KB Output is correct
89 Correct 636 ms 49768 KB Output is correct
90 Correct 627 ms 49860 KB Output is correct
91 Correct 259 ms 49532 KB Output is correct
92 Correct 227 ms 49448 KB Output is correct
93 Correct 525 ms 49640 KB Output is correct
94 Correct 597 ms 49680 KB Output is correct
95 Correct 511 ms 49612 KB Output is correct
96 Correct 539 ms 49520 KB Output is correct
97 Correct 621 ms 49756 KB Output is correct