QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#715556#9491. 生命的循环peaneval_kala41 236ms27672kbC++2314.1kb2024-11-06 12:32:172024-11-06 12:32:19

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 12:32:19]
  • 评测
  • 测评结果:41
  • 用时:236ms
  • 内存:27672kb
  • [2024-11-06 12:32:17]
  • 提交

answer

#pragma GCC optimize(3, "unroll-loops", "no-stack-protector")
#define atsum(l, r) accumulate(l, r, 0)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 0x3f3f3f3f;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
inline void chkmin(T &x, T y) { x = min(x, y); }
template <typename T>
inline void chkmax(T &x, T y) { x = max(x, y); }
namespace FastIO
{
// ------------------------------
#define IN_HAS_NEG
#define OUT_HAS_NEG
#define CHK_EOF
#define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined (_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
    inline char gc() { return getchar(); }
    inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
    INLINE_V constexpr int _READ_SIZE = 1 << 18;
    INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
    inline char gc()
    {
        if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
        {
            _read_ptr = _read_buffer;
            _read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
            if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
        }
        return *_read_ptr++;
    }
#else
    INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
    inline char gc() { return *_read_ptr++; }
#endif
    INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
    INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
    inline void pc(char c)
    {
        *_write_ptr++ = c;
        if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
        {
            fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
            _write_ptr = _write_buffer;
        }
    }
    INLINE_V struct _auto_flush
    {
        ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
    }	_auto_flush;
#endif
#ifdef CHK_EOF
    inline bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
    inline bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
    inline bool _isdigit(char c) { return c & 16; }
    inline bool _isgraph(char c) { return c > 32; }
#endif
    template < class T >
    INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
    template < class T >
    INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
    template < class T >
    INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
    template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
    template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
    template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
    template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
    inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
    inline void read_cstr(char *s)
    {
        char c = gc(); while ( !_isgraph(c) ) c = gc();
        while ( _isgraph(c) ) *s++ = c, c = gc();
        *s = 0;
    }
    inline void read(string &s)
    {
        char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
        while ( _isgraph(c) ) s.push_back(c), c = gc();
    }
#ifdef IN_HAS_NEG
    template < class T, enable_if_t < _is_signed < T >, int > = 0 >
    inline void read(T &x)
    {
        char c = gc(); bool f = true; x = 0;
        while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
        if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
        else     while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
    }
    template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
    template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
    inline void read(T &x)
    {
        char c = gc(); while ( !_isdigit(c) ) c = gc();
        x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
    }
    inline void write(char c) { pc(c); }
    inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
    inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
    template < class T, enable_if_t < _is_signed < T >, int > = 0 >
    inline void write(T x)
    {
        char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
        if ( x >= 0 )  do buffer[digits++] =  ( x % 10 ) | 48, x /= 10; while ( x );
        else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
        while ( digits ) pc(buffer[--digits]);
    }
    template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
    template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
    inline void write(T x)
    {
        char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
        do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
        while ( digits ) pc(buffer[--digits]);
    }
    template < int N > struct _tuple_io_helper
    {
        template < class ...T >
        static inline void _read(tuple < T... > &x)
        { _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
        template < class ...T >
        static inline void _write(const tuple < T... > &x)
        { _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
    };
    template <> struct _tuple_io_helper < 1 >
    {
        template < class ...T >
        static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
        template < class ...T >
        static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
    };
    template < class ...T >
    inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
    template < class ...T >
    inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
    template < class T1, class T2 >
    inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
    template < class T1, class T2 >
    inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
    template < class T1, class ...T2 >
    inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
    template < class ...T >
    inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
    template < class T1, class ...T2 >
    inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
    template < class ...T >
    inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
    template < class T >
    inline void print(const T &x) { write(x); }
    inline void print_cstr(const char *x) { write_cstr(x); }
    template < class T1, class ...T2 >
    inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
    template < class ...T >
    inline void print_cstr(const char *x, const T *...y) { print_cstr(x), pc(32), print_cstr(y...); }
    inline void println() { pc(10); }
    inline void println_cstr() { pc(10); }
    template < class ...T >
    inline void println(const T &...x) { print(x...), pc(10); }
    template < class ...T >
    inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;
template <typename T>
inline void clear(T &x) {
    T y;
    swap(x, y);
}
template <uint32_t mod = 1000000009>
class Modint {
   private:
    static constexpr uint32_t get_r() {
        uint32_t ret = mod;
        for (int i = 0; i < 4; i++) ret *= 2 - mod * ret;
        return ret;
    }
    static constexpr uint32_t r = get_r();
    static constexpr uint32_t n2 = -uint64_t(mod) % mod;
    static_assert(r * mod == 1 && mod < (1 << 30) && mod & 1);
    uint32_t data;

   public:
    constexpr Modint() : data(0) {}
    template <class int_t>
    constexpr Modint(const int_t x)
        : data(reduce(
              uint64_t((sizeof(int_t) < sizeof(uint32_t) ? x : x % int_t(mod)) +
                       mod) *
              n2)){};
    static constexpr uint32_t reduce(const uint64_t x) {
        return (x + uint64_t(uint32_t(x) * (-r)) * mod) >> 32;
    }
    constexpr Modint &operator+=(const Modint &r) {
        if (int32_t(data += r.data - 2 * mod) < 0) {
            data += 2 * mod;
        }
        return *this;
    }
    constexpr Modint &operator-=(const Modint &r) {
        if (int32_t(data -= r.data) < 0) {
            data += 2 * mod;
        }
        return *this;
    }
    constexpr Modint &operator*=(const Modint &r) {
        return data = reduce((uint64_t)data * r.data), *this;
    }
    constexpr Modint &operator/=(const Modint &r) { return *this *= r.inv(); }
    constexpr friend Modint operator+(Modint l, const Modint &r) {
        return l += r;
    }
    constexpr friend Modint operator-(Modint l, const Modint &r) {
        return l -= r;
    }
    constexpr friend Modint operator*(Modint l, const Modint &r) {
        return l *= r;
    }
    constexpr friend Modint operator/(Modint l, const Modint &r) {
        return l /= r;
    }
    constexpr friend bool operator==(Modint l, const Modint &r) {
        return l.value() == r.value();
    }
    constexpr Modint operator-() const { return Modint() - Modint(*this); }
    template <class int_t>
    constexpr Modint pow(int_t r) const {
        Modint res(1), w(*this);
        for (; r; r >>= 1, w *= w)
            if (r & 1) res *= w;
        return res;
    }
    constexpr Modint inv() const { return pow(mod - 2); }
    constexpr uint32_t value() const {
        uint32_t res = reduce(data);
        return res >= mod ? res - mod : res;
    }
};
using modint = Modint<>;
const int N  =1e5 + 10, V = 110;
int n, m, fvv, dfn[N], low[N], st[N], top, dfncnt, scc[N], sccnt, dis[N], val[N], o[V], mx[V];
bool inst[N];
basic_string<pair<int, int> > vec[N];
inline void tarjan(int u) {
    dfn[u] = low[u] = ++dfncnt, st[++top] = u, inst[u] = 1;
    for (auto [v, w] : vec[u])
        if (!dfn[v]) dis[v] = dis[u] + w, tarjan(v), chkmin(low[u], low[v]);
        else if (inst[v]) chkmin(low[u], dfn[v]);
    if (dfn[u] == low[u]) {
        ++sccnt;
        while (st[top] != u) scc[st[top]] = sccnt, inst[st[top--]] = 0;
        scc[st[top]] = sccnt, inst[st[top--]] = 0;
    }
}
bitset<V> g[N][V], f[N][V], tmp[V], ans[V];
void dfs(int u, int t, int r) {
    if (g[u][t].test(r)) return;
    g[u][t].set(r);
    for (auto [v, w] : vec[u]) dfs(v, t, (r + w) % t);
}
void dfs2(int u, int t, int r) {
    if (f[u][t].test(r)) return;
    f[u][t].set(r);
    for (auto [v, w] : vec[u]) {
        int nt = gcd(t, val[scc[v]]);
        dfs2(v, nt, (r + w) % nt);
    }
}
int main() {
    read(n, m, fvv);
    while (m--) {
        int u, v, w;
        read(u, v, w), vec[u] += make_pair(v, w);
    }
    tarjan(1);
    if (!dfn[n]) return println(1), 0;
    for (int u = 1; u <= n; u++)
        for (auto [v, w] : vec[u])
            if (scc[u] == scc[v]) val[scc[u]] = gcd(val[scc[u]], w - dis[v] + dis[u]);
    for (int t = 1; t <= 100; t++) dfs(1, t, 0);
    for (int u = 1; u <= n; u++)
        for (int r = 0; r < val[scc[u]]; r++)
            if (g[u][val[scc[u]]].test(r)) dfs2(u, val[scc[u]], r);
    basic_string<int> qwq;
    for (int t = 1; t <= 100; t++) o[t] = t / gcd(t, 2520), qwq += o[t];
    sort(qwq.begin(), qwq.end()), qwq.erase(unique(qwq.begin(), qwq.end()), qwq.end());
    for (int x = 0; x < 2520; x++) {
        for (int v : qwq) {
            tmp[v].reset(); 
            for (int r = 0; r < v; r++) tmp[v].set(r);
        }
        bool fl = 1;
        for (int i = 1; i <= 100; i++) {
            for (int r = 0; r < o[i] - 1; r++)
                if (f[n][i].test((r * 2520 + x) % i)) tmp[o[i]].set(r);
            if (!tmp[o[i]].any()) {
                fl = 0;
                break;
            }
        }
        if (!fl) continue;
        if ((tmp[4] & (tmp[2] << 2 | tmp[2])).none()) continue;
        if ((tmp[8] & (tmp[4] << 4 | tmp[4])).none()) continue;
        if ((tmp[9] & (tmp[3] << 3 | tmp[3] << 6 | tmp[3])).none()) continue;
        int w;
        for (int i = 1; i <= 100; i++)
            for (int r = 0; r < o[i]; r++)
                if (!f[n][i].test(w = (r * 2520 + x) % i)) {
                    bool ok = 0;
                    if (o[i] == 1) ok = 1;
                    else if (o[i] == 2) ok = tmp[8].test(r) || tmp[8].test(r + 2) || tmp[8].test(r + 4) || tmp[8].test(r + 6);
                    else if (o[i] == 3) ok = tmp[9].test(r) || tmp[9].test(r + 3) || tmp[9].test(r + 6);
                    else if (o[i] == 4) ok = tmp[8].test(r) || tmp[8].test(r + 4);
                    else ok = tmp[o[i]].test(r);
                    if (ok) ans[i].set(w);
                }
    }
    for (int t = 1; t <= 100; t++)
        for (int i = 1; i <= t; i++)
            if (t % i == 0) {
                bool ok = 1;
                for (int j = i; j < t; j++)
                    if (ans[t].test(j - i) ^ ans[t].test(j)) {
                        ok = 0;
                        break;
                    }
                if (ok) {
                    // cerr << "find addi:" << i << endl;
                    int c = i;
                    for (int p = 2; p * p <= c; p++)
                        if (c % p == 0) {
                            int cc = 0;
                            while (c % p == 0) ++cc, c /= p;
                            chkmax(mx[p], cc);
                        }
                    chkmax(mx[c], 1);
                    break;
                }

            }
    modint resx = 1;
    for (int i = 2; i <= 100; i++) // cerr << "find youmo:" << i << ' ' << mx[i] << endl, 
        resx *= modint(i).pow(mx[i]);
    println(resx.value());
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 38ms
memory: 10076kb

input:

30 2000 1
9 19 58
20 17 5
20 17 96
27 20 2
15 28 71
14 18 20
19 24 29
18 13 66
21 17 62
20 17 86
23 20 58
18 26 69
29 18 73
30 26 13
27 17 73
23 15 30
10 8 68
25 6 51
7 4 55
23 13 74
12 8 94
23 29 33
6 8 86
1 8 75
14 30 73
23 27 82
14 26 85
12 28 68
1 27 21
6 8 74
22 13 61
17 5 58
28 3 69
1 25 59
11...

output:

1

result:

ok single line: '1'

Test #2:

score: 1
Accepted
time: 0ms
memory: 10032kb

input:

3000 10000 1
2941 1762 34
1456 1466 41
1279 2756 45
396 2841 46
579 12 78
2654 888 18
1656 237 58
1820 2775 80
426 165 3
994 1141 92
1617 1851 28
2449 2082 75
1438 2206 34
2657 774 78
942 1156 40
2329 176 92
858 2172 84
1161 2798 72
982 435 43
1674 1274 88
2827 979 9
1003 1165 50
907 774 81
1142 204...

output:

1

result:

ok single line: '1'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 8
Accepted
time: 23ms
memory: 9940kb

input:

5 8 2
1 5 0
4 1 0
5 4 0
3 2 2
2 2 2
4 5 2
4 3 0
1 1 0

output:

2

result:

ok single line: '2'

Test #4:

score: 8
Accepted
time: 22ms
memory: 7768kb

input:

7 11 2
1 2 1
2 3 3
3 2 5
2 7 1
3 7 2
1 5 3
5 5 6
5 7 1
1 6 2
6 6 10
6 7 4

output:

60

result:

ok single line: '60'

Test #5:

score: 0
Wrong Answer
time: 23ms
memory: 9784kb

input:

7 15 2
1 2 1
2 2 8
2 7 10
1 3 8
3 3 3
3 7 2
1 4 8
4 4 10
4 7 6
1 5 3
5 5 9
5 7 4
1 6 4
6 6 6
6 7 0

output:

360

result:

wrong answer 1st lines differ - expected: '120', found: '360'

Subtask #3:

score: 11
Accepted

Test #6:

score: 11
Accepted
time: 206ms
memory: 26732kb

input:

5000 5259 3
1 8 5
8 7 1
7 9 5
9 4 2
4 5 4
5 3 1
3 2 2
2 6 1
6 10 3
10 1 4
5 11 46
11 5 38
2 14 14
14 13 22
13 15 12
15 12 14
12 16 21
16 2 15
7 26 0
26 28 2
28 25 1
25 23 2
23 20 4
20 24 1
24 22 1
22 21 1
21 27 3
27 30 0
30 19 4
19 18 3
18 17 3
17 29 2
29 7 1
14 33 12
33 31 13
31 36 11
36 34 5
34 38...

output:

14

result:

ok single line: '14'

Test #7:

score: 11
Accepted
time: 77ms
memory: 18280kb

input:

2000 2189 3
1 2 0
2 1 0
2 3 0
3 4 0
4 2 0
2 5 0
5 2 0
3 6 25
6 3 23
2 18 4
18 16 0
16 8 5
8 9 3
9 19 8
19 12 5
12 23 1
23 24 6
24 10 5
10 15 6
15 17 6
17 21 9
21 22 4
22 7 6
7 25 5
25 11 4
11 20 5
20 13 5
13 14 6
14 2 3
17 26 0
26 17 0
26 28 0
28 27 0
27 26 0
3 93 0
93 70 1
70 158 0
158 95 1
95 189 ...

output:

48

result:

ok single line: '48'

Test #8:

score: 11
Accepted
time: 109ms
memory: 10536kb

input:

100 7000 3
11 14 0
41 73 0
58 2 0
85 30 0
69 59 0
3 84 0
55 87 0
50 66 0
37 89 0
25 100 0
100 63 0
73 30 0
79 83 0
3 84 0
25 28 0
51 57 0
79 47 0
55 19 0
60 68 0
42 53 0
36 47 0
76 32 0
60 78 0
65 71 0
73 15 0
7 61 0
31 19 0
92 32 0
74 21 0
7 43 0
21 56 0
66 5 0
34 88 0
95 5 0
25 55 0
54 88 0
44 97 ...

output:

3

result:

ok single line: '3'

Subtask #4:

score: 10
Accepted

Dependency #3:

100%
Accepted

Test #9:

score: 10
Accepted
time: 175ms
memory: 27672kb

input:

5000 5287 4
1 2 41
1 20 1
20 21 2
21 38 1
38 32 1
32 40 0
40 8 3
8 35 2
35 15 0
15 19 2
19 31 2
31 12 1
12 50 4
50 36 3
36 5 1
5 22 1
22 43 2
43 26 0
26 25 3
25 23 0
23 17 3
17 42 1
42 13 4
13 9 3
9 37 1
37 52 2
52 4 1
4 49 1
49 48 3
48 24 1
24 6 0
6 55 2
55 30 0
30 18 0
18 11 1
11 14 0
14 51 2
51 1...

output:

30

result:

ok single line: '30'

Test #10:

score: 10
Accepted
time: 236ms
memory: 17056kb

input:

5000 10000 4
4998 4999 12
4999 5000 18
5000 4998 42
1 2 17
2 3 43
3 4 12
4 5 32
5 6 10
6 7 45
7 8 22
8 9 17
9 10 45
10 11 33
11 12 1
12 13 10
13 14 2
14 15 43
15 16 27
16 17 23
17 18 23
18 19 30
19 20 9
20 21 19
21 22 30
22 23 20
23 24 8
24 25 29
25 26 18
26 27 34
27 28 4
28 29 47
29 30 36
30 31 32
...

output:

12

result:

ok single line: '12'

Subtask #5:

score: 19
Accepted

Test #11:

score: 19
Accepted
time: 223ms
memory: 13408kb

input:

767 10000 5
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
9 10 1
10 11 1
11 12 1
12 2 1
13 14 1
14 15 1
15 16 1
16 17 1
17 18 1
18 19 1
19 20 1
20 21 1
21 22 1
22 23 1
23 24 1
24 25 1
25 13 1
26 27 1
27 28 1
28 29 1
29 30 1
30 31 1
31 32 1
32 33 1
33 34 1
34 35 1
35 36 1
36 37 1
37 38 1
38 39 1
39 40 1
...

output:

1

result:

ok single line: '1'

Test #12:

score: 19
Accepted
time: 48ms
memory: 7816kb

input:

26 638 5
1 2 0
2 2 72
2 26 0
2 26 1
2 26 6
2 26 7
2 26 12
2 26 13
2 26 18
2 26 19
2 26 24
2 26 25
2 26 30
2 26 31
2 26 36
2 26 37
2 26 42
2 26 43
2 26 48
2 26 49
2 26 54
2 26 55
2 26 60
2 26 61
2 26 66
2 26 67
1 3 0
3 3 25
3 26 0
3 26 1
3 26 2
3 26 3
3 26 5
3 26 6
3 26 7
3 26 8
3 26 10
3 26 11
3 26 ...

output:

381798563

result:

ok single line: '381798563'

Test #13:

score: 19
Accepted
time: 48ms
memory: 8068kb

input:

25 628 5
1 2 0
2 2 90
2 25 0
2 25 2
2 25 5
2 25 6
2 25 7
2 25 8
2 25 10
2 25 11
2 25 12
2 25 14
2 25 17
2 25 18
2 25 19
2 25 21
2 25 26
2 25 27
2 25 28
2 25 29
2 25 30
2 25 32
2 25 35
2 25 36
2 25 37
2 25 38
2 25 40
2 25 41
2 25 42
2 25 44
2 25 47
2 25 48
2 25 49
2 25 51
2 25 56
2 25 57
2 25 58
2 25...

output:

672589923

result:

ok single line: '672589923'

Test #14:

score: 19
Accepted
time: 99ms
memory: 10108kb

input:

127 5541 5
2 2 2
2 127 0
2 127 1
3 3 3
3 127 0
3 127 2
4 4 5
4 127 0
4 127 2
5 5 7
5 127 0
5 127 1
5 127 2
5 127 4
5 127 5
5 127 6
6 6 11
6 127 1
6 127 2
6 127 4
6 127 6
6 127 7
6 127 9
7 7 13
7 127 8
8 8 17
8 127 0
8 127 1
8 127 4
8 127 6
8 127 8
8 127 10
8 127 12
8 127 13
8 127 15
8 127 16
9 9 19
...

output:

1

result:

ok single line: '1'

Test #15:

score: 19
Accepted
time: 33ms
memory: 7816kb

input:

20 396 5
1 2 0
2 2 2
1 3 0
3 3 3
3 20 0
3 20 1
1 4 0
4 4 7
4 20 0
4 20 4
4 20 6
1 5 0
5 5 11
5 20 0
5 20 4
5 20 5
5 20 6
5 20 7
5 20 9
1 6 0
6 6 13
6 20 2
6 20 3
6 20 5
6 20 7
6 20 9
1 7 0
7 7 19
7 20 0
7 20 2
7 20 3
7 20 6
7 20 7
7 20 8
7 20 12
7 20 13
7 20 14
7 20 15
7 20 16
7 20 18
1 8 0
8 8 23
8...

output:

868803081

result:

ok single line: '868803081'

Subtask #6:

score: 0
Wrong Answer

Test #16:

score: 9
Accepted
time: 44ms
memory: 9852kb

input:

25 596 6
1 2 0
2 2 16
2 25 2
2 25 4
2 25 5
2 25 6
2 25 7
2 25 8
2 25 9
2 25 10
2 25 11
2 25 12
2 25 13
2 25 14
1 3 0
3 3 64
3 25 0
3 25 1
3 25 2
3 25 6
3 25 7
3 25 8
3 25 9
3 25 10
3 25 14
3 25 15
3 25 16
3 25 17
3 25 18
3 25 22
3 25 23
3 25 24
3 25 25
3 25 26
3 25 30
3 25 31
3 25 32
3 25 33
3 25 34...

output:

7398268

result:

ok single line: '7398268'

Test #17:

score: 0
Wrong Answer
time: 19ms
memory: 7740kb

input:

8 71 6
1 2 0
2 2 2
1 3 0
3 3 4
3 8 0
3 8 1
3 8 2
1 4 0
4 4 8
4 8 3
4 8 4
1 5 0
5 5 16
5 8 1
5 8 3
5 8 4
5 8 5
5 8 6
5 8 8
5 8 10
5 8 11
5 8 13
5 8 14
5 8 15
1 6 0
6 6 32
6 8 1
6 8 2
6 8 3
6 8 4
6 8 6
6 8 10
6 8 11
6 8 12
6 8 14
6 8 18
6 8 19
6 8 20
6 8 22
6 8 26
6 8 27
6 8 28
6 8 31
1 7 0
7 7 64
7 8...

output:

64

result:

wrong answer 1st lines differ - expected: '16', found: '64'

Subtask #7:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 25ms
memory: 7960kb

input:

15 133 7
1 2 0
2 2 5
2 15 1
2 15 3
2 15 4
1 3 0
3 3 8
3 15 2
3 15 3
3 15 6
1 4 0
4 4 9
4 15 3
4 15 4
4 15 5
4 15 7
1 5 0
5 5 10
5 15 2
5 15 4
5 15 6
5 15 7
5 15 8
5 15 9
1 6 0
6 6 12
6 15 2
6 15 4
6 15 5
6 15 9
6 15 10
6 15 11
1 7 0
7 7 13
7 15 0
7 15 1
7 15 2
7 15 3
7 15 5
7 15 6
7 15 7
7 15 9
7 15...

output:

16150680

result:

wrong answer 1st lines differ - expected: '1', found: '16150680'

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%