QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#749399#2562. Fake Plastic Trees 2arvindr9TL 452ms147620kbC++204.7kb2024-11-15 00:20:272024-11-15 00:20:27

Judging History

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

  • [2024-11-15 00:20:27]
  • 评测
  • 测评结果:TL
  • 用时:452ms
  • 内存:147620kb
  • [2024-11-15 00:20:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif
 
template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << "\033[1;35m" << s << "\033[0;32m = \033[33m" << x << "\033[0m\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << "\033[1;35m" << s.substr(0, i) << "\033[0;32m = \033[33m" << x << "\033[31m | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}

typedef int int2;
#define int __int128
#define pi pair<int, int>
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pi>
#define lep(i,l,r) for(int i=l;i<=r;++i)
#define rep(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define f first
#define s second

long long t;

const int maxn = 1005;
const int maxk = 51;
set<pi> dp[maxn]; // (num components, total overflow)

int2 main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> t;
    while (t--) {
        int n, k, l, r;
        {
            long long a, b, c, d;
            cin >> a >> b >> c >> d;
            n = a;
            k = b;
            l = c;
            r = d;
        }

        vector<int> a(n+1);
        lep(i,1,n) {
            long long x;
            cin >> x;
            a[i] = x;
        }
        vector<vector<int>> adj(n+1);
        lep(i,1,n-1) {
            long long u,v;
            cin >> u >> v;
            adj[u].pb(v);
            adj[v].pb(u);
        }

        vector<int> sub(n+1);

        auto dfs1 = [&](auto &self, int u, int p) -> void {
            int val = a[u];
            for (int v: adj[u]) {
                if (v != p) {
                    self(self,v,u);
                    val += sub[v];
                }
            }
            sub[u] = val;
            // assert(sub[u] >= 0);
        };

        dfs1(dfs1,1,0);

        auto dfs2 = [&](auto &self, int u, int p) -> void {
            set<pi> curdp = {mp(0LL,0LL)};
            int tot = a[u];
            for (int v: adj[u]) {
                if (v != p) {
                    self(self,v,u);
                    tot += sub[v];
                    set<pi> nextdp;
                    for (auto [nc, oc]: curdp) { // maybe this part is too slow?
                        for (auto [nv, ov]: dp[v]) {
                            int nextc = nc + nv;
                            int nexto = oc + ov;
                            int gap = tot - l * nextc - nexto;
                            if (nc + nv <= k and gap <= r) {
                                nextdp.insert({nc+nv,oc+ov});
                            }
                        } 
                    }
                    swap(curdp, nextdp);
                }
            }
            // DEBUG(u,curdp);
            for (auto [nc, oc]: curdp) {
                // remaining stuff is <= R -> might be relevant for future components
                int gap = sub[u] - l * nc - oc;
                if (gap <= r) {
                    dp[u].insert({nc,oc});
                }
                // check if you're allowed to make a new component
                if (l <= gap and gap <= r) {
                    if (nc == k+1) continue;
                    dp[u].insert({nc+1, sub[u] - (nc+1)*l});
                }
            }
        };

        dfs2(dfs2,1,0);

        // DEBUG(dp[1]);
        // DEBUG(dp[2]);
        // DEBUG(dp[3]);
        // DEBUG(dp[4]);

        lep(i,1,k+1) {
            int target_overflow = sub[1] - i * l;
            // DEBUG(i,target_overflow);
            if (dp[1].count({i,target_overflow})) {
                cout << 1;
            } else {
                cout << 0;
            } 
        }
        cout << "\n";

        lep(i,1,n) {
            dp[i].clear();
        }
    }

    
} 

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

3
4 3 1 2
1 1 1 1
1 2
2 3
3 4
4 3 1 2
1 1 1 1
1 2
1 3
1 4
4 3 0 0
1 1 1 1
1 2
1 3
1 4

output:

0111
0011
0000

result:

ok 3 tokens

Test #2:

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

input:

100
10 9 18 50
18 0 9 8 11 11 13 16 9 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 38 50
4 10 11 13 19 6 14 14 20 14
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 26 50
6 1 12 7 1 12 20 2 0 12
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 29 50
16 13 1 17 20 15 0 3 6 7
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10...

output:

0011000000
0010000000
0100000000
0010000000
0011111000
0111100000
0010000000
0010000000
0100000000
0011111000
0110000000
0011000000
0011111100
0100000000
0010000000
0010000000
0010000000
0011000000
0111000000
0011100000
0100000000
0100000000
0100000000
0011000000
0011000000
0011111000
0011111110
001...

result:

ok 100 tokens

Test #3:

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

input:

100
10 9 23 50
13 10 9 11 14 13 11 9 14 14
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 11 50
11 9 9 9 14 7 9 12 14 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 27 50
14 13 9 13 9 13 9 14 14 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 41 50
8 10 10 13 8 6 12 7 10 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
1...

output:

0011000000
0011110000
0010000000
0100000000
0011110000
0100000000
0011110000
0011110000
0011100000
0100000000
0011111100
0100000000
0011100000
0011100000
0100000000
0100000000
0011111000
0011000000
0100000000
0011000000
0011111100
0011100000
0100000000
0100000000
0100000000
0011111000
0011111111
010...

result:

ok 100 tokens

Test #4:

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

input:

100
10 9 17 50
9 8 10 12 12 10 12 10 9 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 19 50
10 9 8 10 12 12 8 11 12 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 46 50
8 8 10 10 10 8 9 10 11 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 9 50
9 8 11 10 11 10 10 11 11 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 ...

output:

0011100000
0011000000
0100000000
0011111110
0011111000
0011111111
0011111000
0100000000
0011110000
0011100000
0100000000
0011100000
0011100000
0100000000
0011110000
0011110000
0011100000
0100000000
0011100000
0011111111
0100000000
0011100000
0011000000
0100000000
0011111100
0011110000
0100000000
001...

result:

ok 100 tokens

Test #5:

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

input:

100
10 9 10 50
10 11 11 10 9 9 11 9 11 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 47 50
9 9 9 11 9 10 10 10 10 9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 49 50
9 10 9 11 11 9 11 10 10 9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 19 50
10 9 11 11 10 11 11 9 9 11
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10...

output:

0011111100
0100000000
0100000000
0011100000
0011110000
0011111111
0011110000
0100000000
0010000000
0100000000
0011111000
0011100000
0100000000
0011110000
0011110000
0011111000
0011111111
0011110000
0011111000
0011110000
0011111100
0011100000
0011000000
0011111111
0100000000
0011111111
0100000000
001...

result:

ok 100 tokens

Test #6:

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

input:

100
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
2 3
3 4
4 5
5 6
6...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #7:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

100
10 9 1793281831312430 2579712950976669
883262428445148 926941407766037 874610589009581 918671242302849 917202064660727 848094660280817 810513162735522 862049976415823 844577745576407 873085228984439
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 1890762965379103 2701769025604615
804306683243252 81402...

output:

0001000000
0001000000
0000100000
0000110000
0001111000
0000100000
0001111111
0000111100
0000111110
0000110000
0001111111
0000111000
0001100000
0001000000
0001100000
0001000000
0000111000
0001111100
0001000000
0001111110
0000110000
0000111100
0001000000
0001111111
0001100000
0001000000
0001000000
000...

result:

ok 100 tokens

Test #8:

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

input:

100
10 9 930392660078775 2806634959843587
930392660078775 905044994636391 985788965763349 912985101122684 987674992837788 921047708030944 933871032635272 924074917003015 906465081663363 976094961177209
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 1883664986961563 2834193280785472
958998107162380 924666...

output:

0000110000
0001000000
0000110000
0001110000
0001000000
0000111100
0001000000
0001000000
0001000000
0001000000
0001000000
0001100000
0001000000
0000111000
0001111000
0001000000
0001000000
0001111110
0001111110
0001000000
0001100000
0001110000
0001000000
0001110000
0000110000
0001110000
0001000000
000...

result:

ok 100 tokens

Test #9:

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

input:

100
10 9 999994984493978 2999942395429624
999994984493978 999939388770002 999967949978069 999931885129608 999990661850258 999984525481315 999963292059809 999975054238715 999981969673638 999985371517271
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 999995366940426 2999765738847089
999995366940426 9999556...

output:

0001100000
0000100000
0001000000
0000110000
0001111110
0000110000
0000111100
0001100000
0001111100
0000110000
0001100000
0000111110
0001100000
0001110000
0001111110
0000111000
0001110000
0001100000
0001100000
0000100000
0001110000
0001000000
0001000000
0001111110
0001111110
0000111110
0000100000
000...

result:

ok 100 tokens

Test #10:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

100
10 9 999999979118283 2999999819537067
999999979118283 999999975440440 999999958461371 999999979080922 999999991176682 999999985652594 999999984182267 999999928654853 999999990678448 999999900203766
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 999999951922360 2999999720940184
999999951922360 9999999...

output:

0000110000
0000111000
0001000000
0000100000
0001100000
0001100000
0001111000
0001110000
0001000000
0001000000
0000111000
0001110000
0001000000
0001111100
0001000000
0000110000
0000100000
0000110000
0001000000
0000110000
0001111111
0001111100
0001111100
0001000000
0001111100
0001110000
0000100000
000...

result:

ok 100 tokens

Test #11:

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

input:

100
10 9 999999999999480 2999999999998668
999999999999480 999999999999623 999999999999311 999999999999062 999999999999032 999999999999420 999999999999039 999999999999706 999999999999079 999999999999883
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 999999999999062 2999999999997761
999999999999062 9999999...

output:

0001110000
0000111110
0000111000
0000111100
0001110000
0000110000
0001100000
0001000000
0000111100
0000100000
0001111000
0001110000
0001111100
0001000000
0000111000
0000110000
0001000000
0001000000
0000110000
0000110000
0001110000
0001111110
0001000000
0001100000
0000111000
0001111100
0001000000
000...

result:

ok 100 tokens

Test #12:

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

input:

100
10 9 809217843509205176 1000000000000000000
819047520089857618 993247146028854493 979024090970900146 946916558454439857 809217843509205176 908857838415646655 809854521131167579 931917514552091282 890253286257158425 872828244740194237
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 810517126615250421 1...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #13:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

100
10 9 990469099227929497 1000000000000000000
997087653799379867 998602320157374700 997500855340614575 998172426490578932 998173419961973183 997315871904813866 990469099227929497 991331794758268536 996329227071528815 994942302495919962
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 990138767121283623 1...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #14:

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

input:

100
10 9 1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 9 100000000...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #15:

score: 0
Accepted
time: 452ms
memory: 147620kb

input:

1
1000 50 3 50
0 0 1 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1...

output:

000000000011111111111111111111111111111111111111111

result:

ok "000000000011111111111111111111111111111111111111111"

Test #16:

score: 0
Accepted
time: 146ms
memory: 54940kb

input:

1
1000 50 16 50
0 2 1 2 0 0 0 1 0 2 1 0 2 2 1 2 2 2 1 0 0 1 1 0 2 1 2 1 2 1 0 0 1 1 0 2 2 2 2 0 0 2 2 2 1 1 0 1 1 1 1 1 0 2 1 1 2 2 2 0 0 2 0 0 1 1 0 0 2 1 2 1 1 1 2 0 0 2 2 2 1 1 1 0 1 0 1 1 2 2 0 0 2 0 1 2 2 0 0 0 2 2 1 2 1 0 2 1 1 0 1 0 0 1 1 0 0 1 0 0 2 2 2 0 0 1 2 2 1 1 2 2 0 2 2 0 1 0 1 0 1 1 ...

output:

000000000000000000001111111111111111111111111111111

result:

ok "000000000000000000001111111111111111111111111111111"

Test #17:

score: 0
Accepted
time: 144ms
memory: 54712kb

input:

1
1000 50 12 50
3 0 3 3 0 1 1 0 0 1 3 2 2 0 0 1 2 1 0 2 2 1 3 2 0 3 3 1 1 3 2 3 3 2 2 2 1 3 2 3 2 1 0 0 2 3 2 0 1 2 3 3 1 3 1 2 0 3 1 1 3 0 0 0 1 3 2 1 2 0 1 0 1 0 2 2 3 0 1 3 1 3 0 0 1 0 0 1 1 1 0 0 3 1 0 0 0 3 3 3 1 1 1 1 1 2 2 3 1 1 1 1 2 3 2 3 3 0 1 0 0 3 0 2 0 2 1 0 0 3 1 1 2 1 2 1 3 0 3 3 1 0 ...

output:

000000000000000000000000000000111111111111111111111

result:

ok "000000000000000000000000000000111111111111111111111"

Test #18:

score: 0
Accepted
time: 11ms
memory: 8376kb

input:

1
1000 50 42 50
1 1 2 0 2 2 2 3 1 4 1 2 2 2 3 4 3 2 3 0 2 1 4 4 2 1 1 3 3 4 3 2 1 1 0 3 2 1 4 3 4 0 0 3 3 2 1 0 1 0 0 4 1 3 3 1 4 0 0 1 4 1 3 2 4 2 4 4 3 4 0 1 0 1 1 1 0 4 3 3 1 2 4 3 4 3 1 2 1 4 3 0 3 4 1 4 4 0 0 2 1 1 4 3 3 2 4 4 1 1 3 3 1 1 4 3 2 3 0 2 4 4 4 1 0 3 2 1 0 3 4 4 3 4 0 2 2 0 1 1 4 2 ...

output:

000000000000000000000000000000000000000000111111000

result:

ok "000000000000000000000000000000000000000000111111000"

Test #19:

score: 0
Accepted
time: 9ms
memory: 8352kb

input:

1
1000 50 44 50
3 2 3 2 1 2 1 3 3 1 2 2 2 2 3 1 2 3 1 2 3 1 1 1 3 1 3 2 2 1 3 1 2 1 1 2 1 1 3 3 3 2 3 2 3 2 1 1 1 2 1 3 1 2 3 1 2 2 1 2 3 2 2 3 2 2 1 2 1 1 2 2 3 2 2 1 2 3 1 3 3 2 3 3 2 1 1 2 2 1 3 2 2 3 3 3 3 3 3 1 3 2 2 2 1 2 3 1 3 2 1 3 3 1 1 2 1 3 2 2 2 1 2 2 1 1 3 1 2 1 3 3 2 1 2 3 1 2 1 1 3 3 ...

output:

000000000000000000000000000000000000000011111000000

result:

ok "000000000000000000000000000000000000000011111000000"

Test #20:

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

input:

1
1000 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #21:

score: 0
Accepted
time: 136ms
memory: 52724kb

input:

1
1000 50 9067775517233793 27568152627261704
824143955544587 927579399534651 981801757217093 873773052413201 960257095164910 952261320093379 822434086320207 800147963710845 932219523834279 993157363400641 894323153846989 891533209662841 816940466685934 850744085351539 876674222750886 984981230477671...

output:

000000000000000000000000000000000111111111111111111

result:

ok "000000000000000000000000000000000111111111111111111"

Test #22:

score: 0
Accepted
time: 149ms
memory: 53348kb

input:

1
1000 50 10392950962364217 29677624285662191
952249828947457 989340248861758 922815904253124 988185672550932 901211610272775 916246836895084 911821518650392 969679688724958 917576531870585 962895648801013 960927472536139 985041956652122 955734234153218 924834554870256 927427626795671 99743959744383...

output:

000000000000000000000000000000001111111111111111111

result:

ok "000000000000000000000000000000001111111111111111111"

Test #23:

score: 0
Accepted
time: 4ms
memory: 7548kb

input:

1
1000 50 27998332064717309 30998401244356277
999923676529412 999964127454061 999901368076070 999965096214353 999973159921658 999940703209340 999901590913383 999994884859099 999948950882947 999900197152876 999903336019181 999974160658209 999963256360445 999962463135617 999900477973929 99993606716768...

output:

000000000000000000000000000000001110000000000000000

result:

ok "000000000000000000000000000000001110000000000000000"

Test #24:

score: 0
Accepted
time: 198ms
memory: 68612kb

input:

1
1000 50 4999999774482822 30999998337007262
999999966252791 999999947367745 999999905851118 999999999785542 999999955225626 999999997492014 999999907762313 999999913104525 999999962556159 999999998434960 999999943955799 999999938987651 999999919770925 999999918953335 999999940886692 999999936772000...

output:

000000000000000000000000000000000111111111111111111

result:

ok "000000000000000000000000000000000111111111111111111"

Test #25:

score: 0
Accepted
time: 94ms
memory: 35284kb

input:

1
1000 50 15999999999993257 30999999999985579
999999999999979 999999999999771 999999999999854 999999999999281 999999999999698 999999999999830 999999999999712 999999999999139 999999999999804 999999999999673 999999999999099 999999999999059 999999999999374 999999999999943 999999999999373 99999999999966...

output:

000000000000000000000000000000001111111111111111111

result:

ok "000000000000000000000000000000001111111111111111111"

Test #26:

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

input:

1
1000 50 800012418361959872 1000000000000000000
947369818918026096 942007600439311022 918881052204508717 898991866868830953 878449678306763381 921674051503661838 867715520616597795 880692389166218687 831246240027360885 977061124063742870 948796346350621716 937890416222692974 804321876310495686 8665...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #27:

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

input:

1
1000 50 990018432224876243 1000000000000000000
995440746039941717 991669382178948943 991935198890996390 993125966265179373 992741274852450701 991093927814885373 998609998029047476 999242003070483925 995948056384085956 995167742492048978 999099639351689010 992585906640490261 995767554302569406 9975...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #28:

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

input:

1
1000 50 1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #29:

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

input:

100
10 9 15 50
7 14 18 19 7 3 13 5 6 8
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 36 50
13 3 3 7 7 11 9 19 0 10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 20 50
6 3 3 19 12 9 17 13 20 20
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 20 50
0 11 16 13 7 18 7 13 15 2
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9...

output:

0011000000
0100000000
0001100000
0010000000
0010000000
0010000000
0010000000
0010000000
0011100000
0011100000
0010000000
0010000000
0111110000
0100000000
0100000000
0011000000
0010000000
0010000000
0100000000
0011100000
0100000000
0100000000
0011000000
0100000000
0011000000
0100000000
0100000000
010...

result:

ok 100 tokens

Test #30:

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

input:

100
10 9 23 50
15 12 5 6 8 14 12 14 8 15
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 19 50
10 6 6 9 8 5 8 7 14 14
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 40 50
12 6 8 8 6 10 10 7 10 13
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 17 50
12 7 12 11 9 13 7 8 14 8
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 ...

output:

0011000000
0010000000
0100000000
0011000000
0011000000
0011100000
0010000000
0010000000
0010000000
0011000000
0010000000
0011000000
0010000000
0011110000
0100000000
0011000000
0011000000
0010000000
0010000000
0010000000
0010000000
0011111000
0010000000
0010000000
0010000000
0011000000
0010000000
001...

result:

ok 100 tokens

Test #31:

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

input:

100
10 9 23 50
11 9 9 10 11 12 12 11 9 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 20 50
8 9 8 9 12 11 12 9 12 8
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 22 50
12 11 12 12 12 11 9 8 9 10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 23 50
8 8 11 9 11 10 12 12 12 12
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10...

output:

0010000000
0010000000
0011000000
0010000000
0010000000
0011000000
0011000000
0011000000
0011000000
0010000000
0011000000
0011000000
0011000000
0010000000
0010000000
0010000000
0010000000
0010000000
0011000000
0011000000
0011000000
0011000000
0010000000
0010000000
0011000000
0011000000
0011000000
001...

result:

ok 100 tokens

Test #32:

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

input:

100
10 9 19 50
9 11 11 9 9 9 11 9 11 10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 21 50
9 11 10 9 10 10 10 10 9 11
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 20 50
10 9 9 9 10 11 9 11 10 10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 20 50
9 11 9 9 9 11 9 9 9 11
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 ...

output:

0011000000
0010000000
0010000000
0011000000
0010000000
0010000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0010000000
0010000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0010000000
0011000000
0011000000
0011000000
0011000000
001...

result:

ok 100 tokens

Test #33:

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

input:

100
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 50 50
50 50 50 50 50 50 50 50 50 50
1 2
1 3
2 4
2 5
3 6
3...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #34:

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

input:

100
10 9 903043839725508 2707074196186122
903043839725508 973202099194209 829984009795447 986683458077958 814248852378660 913353241639790 932268030485567 909500413864783 810890324243381 885601228094769
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 870280273045333 2782075394986519
870280273045333 9768762...

output:

0001111000
0001111100
0001000000
0001000000
0001111110
0001110000
0001100000
0001111100
0001000000
0001110000
0001110000
0001111110
0001111111
0001000000
0001110000
0001111000
0001111110
0001000000
0001111100
0001000000
0001100000
0001111110
0001000000
0001111100
0001111110
0001111111
0001000000
000...

result:

ok 100 tokens

Test #35:

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

input:

100
10 9 1866121251624223 2869996673058882
931154008118068 934967243506155 970998156812759 901096078239411 955203367470562 977334463478406 921664052767717 906995284181461 996247332277737 983302658795461
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 1935232744615275 2894968873722214
936884591729852 99834...

output:

0001000000
0001000000
0001000000
0001111110
0001000000
0001000000
0001110000
0001111000
0001111000
0001000000
0001111000
0001111110
0001000000
0001111111
0001000000
0001000000
0001100000
0001110000
0001000000
0001000000
0001000000
0001111110
0001110000
0001000000
0001100000
0001000000
0001000000
000...

result:

ok 100 tokens

Test #36:

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

input:

100
10 9 1999908914873019 2999856081168166
999960368017239 999986862183619 999983583230665 999912311844344 999964885222833 999928338194639 999944159742862 999947307305803 999919747391213 999944029650186
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 999956150993101 2999851224959263
999956150993101 999917...

output:

0001000000
0001110000
0001110000
0001000000
0001111100
0001111111
0001000000
0001000000
0001000000
0001110000
0001110000
0001111000
0001110000
0001000000
0001110000
0001111110
0001000000
0001111110
0001111000
0001111110
0001111111
0001000000
0001000000
0001111110
0001000000
0001111111
0001000000
000...

result:

ok 100 tokens

Test #37:

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

input:

100
10 9 999999932589125 2999999923145214
999999932589125 999999955609543 999999994910385 999999952296996 999999978882996 999999934455964 999999993778865 999999921122714 999999965213291 999999955253825
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 999999911464789 2999999920926873
999999911464789 9999999...

output:

0001111110
0001111100
0001110000
0001000000
0001000000
0001111100
0001000000
0001111000
0001000000
0001111000
0001110000
0001111000
0001000000
0001000000
0001000000
0001000000
0001000000
0001111100
0001000000
0001111111
0001000000
0001000000
0001000000
0001111111
0001100000
0001111100
0001000000
000...

result:

ok 100 tokens

Test #38:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

100
10 9 999999999999085 2999999999998858
999999999999085 999999999999590 999999999999912 999999999999229 999999999999232 999999999999506 999999999999440 999999999999208 999999999999464 999999999999692
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 999999999999284 2999999999998827
999999999999284 9999999...

output:

0001111111
0001111100
0001111000
0001000000
0001000000
0001111110
0001111100
0001000000
0001111100
0001111000
0001110000
0001111111
0001000000
0001000000
0001110000
0001100000
0001111111
0001111110
0001111111
0001111111
0001000000
0001111111
0001111000
0001110000
0001000000
0001111111
0001000000
000...

result:

ok 100 tokens

Test #39:

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

input:

100
10 9 881395859836029858 1000000000000000000
974093279292304002 949869240945029334 888242175265700181 909599751947474264 943499279072869120 881395859836029858 947124920770043581 956764868151177639 905534014770395870 956527416514760704
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 843028099553504974 1...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #40:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

100
10 9 991162912473331795 1000000000000000000
992164206414219639 992903059539442501 994668354511995636 993733851343822589 991162912473331795 997443699292478151 994647361327718197 991942440905700078 996863794272345801 993480892568797038
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 990182020218925256 1...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #41:

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

input:

100
10 9 1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
10 9 100000000...

output:

0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
0000000001
000...

result:

ok 100 tokens

Test #42:

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

input:

1
1000 50 23 50
0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 0 1 0 1 1 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 ...

output:

000000000000001100000000000000000000000000000000000

result:

ok "000000000000001100000000000000000000000000000000000"

Test #43:

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

input:

1
1000 50 23 50
1 2 0 0 0 0 2 1 0 0 1 0 1 2 0 2 0 0 1 1 2 2 0 2 2 2 2 1 0 0 0 1 2 2 1 1 2 1 2 1 2 0 0 0 0 1 1 0 2 0 1 1 0 2 2 2 0 1 1 2 0 1 0 0 1 1 2 1 0 2 0 0 2 0 1 0 2 2 0 0 0 1 0 2 1 2 0 1 0 0 2 1 0 1 2 0 2 0 1 2 2 1 0 0 0 1 2 1 1 0 1 1 2 2 1 0 0 0 1 1 0 2 2 1 2 2 2 1 1 2 2 2 0 1 1 0 0 2 0 0 1 1 ...

output:

000000000000000000000000000001110000000000000000000

result:

ok "000000000000000000000000000001110000000000000000000"

Test #44:

score: 0
Accepted
time: 13ms
memory: 4308kb

input:

1
1000 50 21 50
1 0 1 2 0 1 0 0 2 3 0 3 0 0 2 1 3 1 2 0 3 1 2 1 1 3 1 3 1 0 0 2 1 2 0 0 0 2 2 3 0 3 2 0 0 1 1 1 3 0 3 0 3 2 2 3 3 0 1 2 1 1 1 0 1 1 3 3 0 0 0 3 1 1 0 2 0 3 0 3 2 3 0 2 2 0 1 2 0 2 0 3 0 0 1 0 3 2 1 3 3 3 1 0 2 3 1 2 3 3 2 1 0 0 0 1 1 0 0 1 0 1 3 1 3 0 1 2 1 3 3 0 1 3 1 2 1 3 1 2 1 3 ...

output:

000000000000000000000000000000000000000111111111111

result:

ok "000000000000000000000000000000000000000111111111111"

Test #45:

score: 0
Accepted
time: 28ms
memory: 4408kb

input:

1
1000 50 16 50
2 4 4 4 0 1 3 3 4 2 1 1 3 0 4 4 4 1 3 4 1 3 3 3 0 1 2 0 2 3 3 1 0 3 4 2 4 0 2 1 0 0 1 4 4 3 3 0 4 4 1 4 3 4 4 4 2 2 3 4 1 1 1 3 1 4 0 3 2 2 0 2 4 4 1 2 2 2 1 3 1 1 2 4 0 4 1 0 4 4 0 2 4 1 3 2 1 3 0 1 4 0 0 3 4 3 0 1 2 3 2 0 1 1 0 1 3 1 1 2 4 1 4 1 2 1 3 4 4 4 1 4 3 0 4 3 2 2 1 0 4 1 ...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #46:

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

input:

1
1000 50 25 50
2 3 2 3 3 2 1 1 2 1 1 3 1 3 3 3 1 2 2 3 2 2 1 1 1 1 3 1 3 3 3 1 3 3 3 1 2 3 3 3 2 3 1 2 1 3 2 2 3 1 2 3 3 1 3 1 3 3 2 2 3 1 1 3 2 1 2 1 3 1 3 1 3 1 1 3 3 2 3 1 3 3 2 3 2 2 3 2 3 1 2 1 1 3 2 1 2 2 3 3 3 3 3 2 1 3 2 2 2 3 3 1 1 3 2 3 3 3 3 2 1 1 2 1 2 3 2 1 3 1 2 1 1 2 2 1 3 2 1 1 1 3 ...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #47:

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

input:

1
1000 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50...

output:

000000000000000000000000000000000000000000000000000

result:

ok "000000000000000000000000000000000000000000000000000"

Test #48:

score: -100
Time Limit Exceeded

input:

1
1000 50 13403743128063067 28540184163713846
844358050287008 941099799527877 909650229455745 915414006020742 916956970131330 942749789591252 809881431452492 920530662917571 820491993057471 930698204102126 910235146807825 919353997191450 810996409096514 886426944686826 854848054473256 90913715981135...

output:


result: