QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865895#4927. Bounded Spanning TreeZbyszek990 760ms192464kbC++146.0kb2025-01-22 06:16:452025-01-22 06:16:46

Judging History

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

  • [2025-01-22 06:16:46]
  • 评测
  • 测评结果:0
  • 用时:760ms
  • 内存:192464kb
  • [2025-01-22 06:16:45]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;

const int tree_siz = (1 << 20)-1;
int drzewo[tree_siz];

int get_min(int akt, int p1, int p2, int s1, int s2)
{
    if(p2 < s1 || p1 > s2) return 1e9;
    if(p1 >= s1 && p2 <= s2) return drzewo[akt-1];
    return min(get_min(akt*2,p1,(p1+p2)/2,s1,s2),get_min(akt*2+1,(p1+p2)/2+1,p2,s1,s2));
}

void upd(int v)
{
    drzewo[v-1] = min(drzewo[v*2-1],drzewo[v*2]);
    if(v != 1) upd(v/2);
}

void change(int ind, int x)
{
    drzewo[tree_siz/2+ind] = x;
    upd((tree_siz/2+ind+1)/2);
}

vector<pii> graph[500002];
int ans[500003];
int l_border[500002];
int r_border[500002];
pii edges[500002];
vi starts_list[500002];
int depth[500002];
int cur_pre = 0;
int pre[500002];
int max_pre[500002];
pii jump[500002][19];
int pop_edge[500002];

vector<pair<int,pii>> del_list[500002];
multiset<int> min_val[500002];

pii lca(int a, int b)
{
    int ans = 0;
    if(depth[a] < depth[b]) swap(a,b);
    for(int bit = 18; bit >= 0; bit--)
    {
        if(depth[jump[a][bit].ff] >= depth[b])
        {
            ans = max(ans,jump[a][bit].ss);
            a = jump[a][bit].ff;
        }
    }
    if(a == b) return {ans,a};
    for(int bit = 18; bit >= 0; bit--)
    {
        if(jump[a][bit].ff != jump[b][bit].ff)
        {
            ans = max(ans,jump[a][bit].ss);
            ans = max(ans,jump[b][bit].ss);
            a = jump[a][bit].ff;
            b = jump[b][bit].ff;
        }
    }
    ans = max(ans,jump[a][0].ss);
    ans = max(ans,jump[b][0].ss);
    return {ans,jump[a][0].ff};
}

void dfs(int v, int pop, int e, int dep = 0)
{
    pop_edge[v] = e;
    pre[v] = cur_pre++;
    max_pre[v] = pre[v];
    jump[v][0] = {pop, l_border[e]+1};
    depth[v] = dep++;
    forall(it,graph[v])
    {
        if(it.ff != pop)
        {
            dfs(it.ff,v,it.ss,dep);
            max_pre[v] = max_pre[it.ff];
        }
    }
}

void upd_path(int v)
{
    if(siz(min_val[v]) == 0)
    {
        change(pre[v],1e9);
    }
    else
    {
        change(pre[v],*min_val[v].begin());
    }
}

void dfs_path(int v, int pop)
{
    forall(it,graph[v])
    {
        if(it.ff != pop)
        {
            dfs_path(it.ff,v);
        }
    }
    forall(it,del_list[v])
    {
        min_val[it.ss.ff].erase(min_val[it.ss.ff].find(it.ff));
        min_val[it.ss.ss].erase(min_val[it.ss.ss].find(it.ff));
        upd_path(it.ss.ff);
        upd_path(it.ss.ss);
    }
    upd_path(v);
    //cout << v << " v\n";
    //cout << get_min(1,0,tree_siz/2,pre[v]+1,max_pre[v]) << " new_min\n";
    r_border[pop_edge[v]] = min(r_border[pop_edge[v]],get_min(1,0,tree_siz/2,pre[v],max_pre[v]));
}

void solve()
{
    int n,m;
    cin >> n >> m;
    rep(i,m) ans[i] = -1;
    rep2(i,1,n) graph[i] = {};
    rep2(i,1,n) del_list[i] = {};
    rep2(i,1,n) min_val[i] = {};
    rep(i,m)
    {
        int a,b,l,r;
        cin >> a >> b >> l >> r;
        if(i < n-1)
        {
            graph[a].pb({b,i});
            graph[b].pb({a,i});
        }
        edges[i] = {a,b};
        l_border[i] = l;
        r_border[i] = r;
    }
    cur_pre = 0;
    dfs(1,1,m);
    rep2(bit,1,18)
    {
        rep2(i,1,n)
        {
            jump[i][bit].ff = jump[jump[i][bit-1].ff][bit-1].ff;
            jump[i][bit].ss = max(jump[i][bit-1].ss,jump[jump[i][bit-1].ff][bit-1].ss);
        }
    }
    rep2(i,n-1,m-1)
    {
        pii l = lca(edges[i].ff,edges[i].ss);
       // cout << edges[i].ff << " " << edges[i].ss << " " << l.ff << " " << l.ss << " edge\n";
        l_border[i] = max(l_border[i],l.ff);
        min_val[edges[i].ff].insert(r_border[i]-1);
        min_val[edges[i].ss].insert(r_border[i]-1);
        del_list[l.ss].pb({r_border[i]-1,{edges[i].ff,edges[i].ss}});
    }
    dfs_path(1,1);
    rep(i,n)
    {
        change(i,1e9);
    }
    rep(i,m)
    {
        if(l_border[i] > r_border[i])
        {
            cout << "xd2\n";
            return;
        }
    }
    rep(i,m)
    {
        starts_list[l_border[i]].pb(i);
    }
    set<pii> s;
    rep2(i,1,m)
    {
        forall(it,starts_list[i])
        {
            s.insert({r_border[it],it});
        }
        if(siz(s) != 0)
        {
            auto it = s.begin();
            while((*it).ff < i)
            {
                s.erase(it);
                if(siz(s) == 0) break;
                it = s.begin();
            }
            if(siz(s) != 0)
            {
                int v = (*it).ss;
                s.erase(it);
                ans[v] = i;
            }
        }
    }
    rep2(i,1,m) starts_list[i] = {};
    rep(i,m)
    {
        if(ans[i] == -1)
        {
            cout << "xd1\n";
            return;
        }
    }
    cout << "YES\n";
    rep(i,m)
    {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    rep(i,tree_siz) drzewo[i] = 1e9;
    //random_start();
    int t = 1;
    cin >> t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 4
Accepted
time: 669ms
memory: 192464kb

input:

1
500001 500000
254401 281557 349855 349855
181158 183050 7695 7695
168649 393239 182447 182447
275491 426002 407013 407013
412840 430191 81351 81351
180729 474744 468590 468590
167128 233022 352396 352396
56562 410078 411755 411755
28611 28934 27783 27783
250615 303207 495889 495889
348947 377767 2...

output:

YES
349855 7695 182447 407013 81351 468590 352396 411755 27783 495889 279148 126532 371490 46443 75037 440945 17872 376183 227217 256463 268704 93994 142674 221161 313215 423148 348655 110097 61558 138416 182869 460629 101134 233433 485321 293910 161637 31401 388370 43691 103888 258050 186588 285649...

result:

ok all is ok (1 test case)

Test #2:

score: 4
Accepted
time: 615ms
memory: 161712kb

input:

1
300001 500000
146540 236321 23350 23350
110737 197257 49315 49315
87807 244200 2878 2878
27529 179675 90834 90834
39761 204225 209751 209751
175226 239307 945 945
25136 248902 243667 243667
215811 229229 48401 48401
152882 243088 63537 63537
136220 210273 244339 244339
31127 43815 196573 196573
31...

output:

YES
23350 49315 2878 90834 209751 945 243667 48401 63537 244339 196573 170759 346610 33502 342292 86136 71174 153543 40008 300022 342991 305551 95289 63927 127147 133670 78873 57350 134796 242512 238031 153963 69392 220900 21326 171023 3218 211851 322418 63540 88200 109095 157709 6644 136208 86952 2...

result:

ok all is ok (1 test case)

Test #3:

score: 4
Accepted
time: 760ms
memory: 173876kb

input:

1
250001 500000
68287 196901 480106 480106
49342 196901 304518 304518
22416 49342 304522 304522
22416 155670 304523 304523
64466 155670 298516 298516
64466 91061 298511 298511
91061 107764 270019 270019
107764 145633 270023 270023
9967 145633 270022 270022
9967 74786 270020 270020
35298 74786 260981...

output:

YES
480106 304518 304522 304523 298516 298511 270019 270023 270022 270020 260981 260987 260975 260980 260999 260988 260553 260552 260551 255267 255249 255252 255206 255247 255246 255192 255270 255224 255251 255255 255296 255277 255189 255254 255245 255239 255217 255250 255289 255190 255276 255223 25...

result:

ok all is ok (1 test case)

Test #4:

score: 4
Accepted
time: 684ms
memory: 154168kb

input:

1
200001 500000
98193 105041 166701 166701
27762 114229 186133 186133
75089 79073 10507 10507
17865 143051 14801 14801
61475 66112 65966 65966
95929 145141 111474 111474
48331 68416 51667 51667
84658 174834 185681 185681
58072 88891 182212 182212
70612 148690 33041 33041
16155 127708 166666 166666
6...

output:

YES
166701 186133 10507 14801 65966 111474 51667 185681 182212 33041 166666 174410 126973 124348 104 167323 109299 22852 163302 119217 152431 288663 55933 2494 119959 58498 108854 313804 18466 166913 48980 9910 343607 193963 105226 272155 404993 191288 158308 131805 92742 84214 63930 160422 96427 12...

result:

ok all is ok (1 test case)

Test #5:

score: 4
Accepted
time: 652ms
memory: 146552kb

input:

1
100001 500000
27575 40895 44938 44938
3625 19411 38012 38012
3655 84852 11318 11318
1152 91041 28632 28632
221 39962 65491 65491
35918 79361 78583 78583
41888 68339 40937 40937
82334 93242 62129 62129
66333 67583 113798 113798
75883 82560 2019 2019
43643 57947 122462 122462
16229 42734 54831 54831...

output:

YES
44938 38012 11318 28632 65491 78583 40937 62129 113798 2019 122462 54831 63084 16263 70129 58780 69845 51401 33811 865 27448 134237 60986 98507 57992 123479 8086 75165 12759 68854 23507 138812 87299 48771 33602 41920 53104 17098 132939 44566 25731 172500 15616 100033 9986 83815 20839 27119 1501 ...

result:

ok all is ok (1 test case)

Test #6:

score: 0
Wrong Answer
time: 251ms
memory: 88756kb

input:

100
2501 4850
1396 1781 772 772
1019 1580 1529 1529
1146 2063 2944 2944
1883 1912 158 158
443 1995 1378 1378
450 871 504 504
1737 2297 2571 2571
447 1804 3367 3367
1159 1917 1789 1789
1478 2444 2775 2775
1783 2412 479 479
2245 2412 2839 2839
73 1403 4729 4729
747 2463 1469 1469
1107 2377 2034 2034
1...

output:

YES
772 1529 2944 158 1378 504 2571 3367 1789 2775 479 2839 4729 1469 2034 2085 1526 747 1638 1356 2158 979 1042 290 919 1304 1555 430 1380 301 1100 2407 900 4497 1318 958 878 432 667 594 1152 763 552 642 3625 463 2885 2992 1630 851 4742 893 2265 1999 83 348 2176 212 3311 629 3246 1360 2114 186 1457...

result:

wrong answer Token parameter [name=Yes/No] equals to "xd2", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 2)

Subtask #2:

score: 0
Wrong Answer

Test #22:

score: 6
Accepted
time: 6ms
memory: 84564kb

input:

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

output:

YES
3 8 5 2 1 6 10 9 7 4 

result:

ok all is ok (1 test case)

Test #23:

score: 6
Accepted
time: 5ms
memory: 84568kb

input:

1
9 9
1 2 1 3
1 7 7 8
4 9 2 7
5 9 1 3
1 4 1 6
3 9 5 6
4 6 4 6
5 8 8 8
4 5 8 9

output:

YES
1 7 6 2 3 5 4 8 9 

result:

ok all is ok (1 test case)

Test #24:

score: 6
Accepted
time: 8ms
memory: 84440kb

input:

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

output:

YES
9 1 6 3 4 2 8 5 10 7 

result:

ok all is ok (1 test case)

Test #25:

score: 6
Accepted
time: 10ms
memory: 82524kb

input:

1
9 9
4 8 6 9
5 8 2 4
1 5 4 6
1 9 2 3
3 9 1 1
3 7 3 4
6 7 9 9
2 6 3 8
5 7 4 8

output:

YES
8 3 5 2 1 4 9 6 7 

result:

ok all is ok (1 test case)

Test #26:

score: 6
Accepted
time: 8ms
memory: 84440kb

input:

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

output:

YES
2 9 3 5 1 6 10 7 8 4 

result:

ok all is ok (1 test case)

Test #27:

score: 6
Accepted
time: 7ms
memory: 86492kb

input:

1
9 9
2 8 8 9
2 7 5 5
2 4 1 2
2 5 4 4
1 2 2 3
2 3 7 9
2 6 2 7
2 9 5 7
4 5 7 8

output:

YES
8 5 1 4 2 9 3 6 7 

result:

ok all is ok (1 test case)

Test #28:

score: 6
Accepted
time: 8ms
memory: 86612kb

input:

2
4 5
2 3 1 1
2 4 2 3
1 2 5 5
2 3 3 3
2 4 4 5
4 5
2 3 1 2
1 2 1 2
1 4 3 3
3 4 4 4
1 3 5 5

output:

YES
1 2 5 3 4 
YES
1 2 3 4 5 

result:

ok all is ok (2 test cases)

Test #29:

score: 0
Wrong Answer
time: 7ms
memory: 84440kb

input:

3
3 3
1 3 1 2
1 2 3 3
1 2 1 2
3 3
1 2 1 1
1 3 2 3
2 3 3 3
3 3
2 3 3 3
1 2 2 3
2 3 1 1

output:

xd2
YES
1 2 3 
xd2

result:

wrong answer Token parameter [name=Yes/No] equals to "xd2", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #45:

score: 10
Accepted
time: 6ms
memory: 82408kb

input:

1
501 500
127 170 433 434
26 98 284 285
179 379 82 82
136 270 253 254
100 391 474 476
175 393 170 171
247 311 223 225
32 318 270 270
87 434 294 294
335 417 308 310
249 356 292 294
327 331 42 44
325 498 334 336
73 133 260 262
276 394 493 495
74 289 330 331
29 83 244 245
7 486 482 483
115 368 90 90
22...

output:

YES
433 284 82 254 476 170 224 270 294 308 293 44 336 261 494 331 244 482 90 277 32 115 416 106 240 386 479 444 125 500 488 306 399 86 474 408 455 458 15 87 42 141 24 128 33 383 29 342 333 381 448 214 346 365 2 25 397 13 499 357 326 310 391 139 366 487 449 361 498 285 436 153 481 412 83 328 84 187 3...

result:

ok all is ok (1 test case)

Test #46:

score: 10
Accepted
time: 8ms
memory: 84584kb

input:

1
501 500
129 176 247 250
72 179 289 289
170 435 422 422
135 320 255 256
126 397 150 150
25 112 29 29
341 422 112 112
68 176 419 421
83 208 266 267
111 470 144 149
212 488 163 165
109 261 468 468
457 478 500 500
298 426 427 432
61 408 459 464
235 440 297 302
114 117 307 307
132 448 37 38
128 380 219...

output:

YES
247 289 422 255 150 29 112 419 266 146 163 468 500 431 462 299 307 37 220 428 358 166 11 122 66 265 416 413 435 483 13 317 83 406 454 242 52 94 397 202 195 4 56 62 291 456 135 310 143 252 264 487 54 363 118 366 256 467 286 244 1 22 73 180 196 229 386 472 475 383 250 238 153 49 104 233 486 414 23...

result:

ok all is ok (1 test case)

Test #47:

score: 10
Accepted
time: 6ms
memory: 82536kb

input:

1
501 500
277 399 197 204
33 426 390 390
202 417 268 272
223 466 15 23
195 379 85 94
100 203 16 22
184 245 142 144
188 474 117 122
195 353 139 143
62 373 412 416
383 390 319 327
40 108 143 153
67 366 53 56
18 325 172 182
272 314 135 137
51 86 237 247
77 313 399 408
22 199 29 36
18 132 422 423
97 345...

output:

YES
201 390 270 20 89 16 142 121 139 414 325 150 53 176 135 242 404 31 422 355 12 313 39 468 292 120 99 491 211 289 88 169 437 32 497 371 205 314 3 19 180 128 295 2 331 421 101 223 360 241 488 143 66 212 474 118 367 258 158 387 285 483 219 348 484 369 342 475 480 271 244 339 405 441 264 226 332 402 ...

result:

ok all is ok (1 test case)

Test #48:

score: 10
Accepted
time: 7ms
memory: 82416kb

input:

1
501 500
212 481 169 188
28 427 404 420
339 466 43 62
229 281 111 126
89 143 234 238
333 444 160 168
288 484 431 451
177 432 441 453
384 407 418 427
146 340 118 118
92 249 467 479
53 469 396 398
63 70 174 180
54 367 8 19
285 360 153 164
67 389 286 291
91 442 99 104
1 455 58 67
207 309 453 472
286 4...

output:

YES
182 413 57 117 235 166 442 445 420 118 472 396 175 13 159 288 99 62 467 23 82 44 494 432 167 153 4 401 25 473 362 119 146 202 270 490 203 220 302 200 223 477 247 71 395 199 116 398 114 227 233 367 154 83 105 284 439 245 400 485 340 410 163 342 5 470 226 46 155 321 304 231 177 421 360 389 333 438...

result:

ok all is ok (1 test case)

Test #49:

score: 10
Accepted
time: 9ms
memory: 84584kb

input:

1
501 500
183 475 152 172
6 264 94 97
102 116 454 461
332 436 250 258
275 339 11 23
109 383 491 500
12 251 156 165
409 496 253 282
319 386 465 469
130 292 121 123
30 333 21 23
40 194 254 255
86 345 338 348
73 434 99 118
119 450 221 228
246 350 35 51
186 255 99 102
182 279 392 413
206 332 247 250
128...

output:

YES
165 94 454 251 13 491 156 277 465 121 21 254 339 107 224 40 99 405 247 197 478 248 404 199 161 269 148 363 412 371 453 444 481 426 296 283 73 316 189 297 244 354 169 246 341 488 436 245 448 280 179 220 500 68 6 7 298 358 227 406 343 119 437 39 391 51 411 252 142 88 475 62 382 345 266 291 83 309 ...

result:

ok all is ok (1 test case)

Test #50:

score: 10
Accepted
time: 6ms
memory: 84592kb

input:

1
501 500
56 261 38 63
139 152 248 251
173 435 92 131
254 445 21 36
74 246 202 208
52 442 422 447
328 340 434 466
179 434 92 126
200 241 127 132
48 294 183 203
72 271 147 172
42 382 245 265
330 466 349 368
59 216 120 125
279 443 359 381
469 478 292 309
51 100 21 39
186 475 275 299
94 495 420 429
323...

output:

YES
45 248 121 26 202 437 451 110 127 193 164 253 354 120 366 298 28 287 421 319 179 461 445 394 220 350 27 302 464 244 83 12 61 443 95 59 432 257 395 138 488 42 429 477 372 13 328 76 406 224 460 499 104 133 492 315 209 195 19 277 55 428 208 472 474 483 11 223 390 270 376 410 156 20 462 311 409 300 ...

result:

ok all is ok (1 test case)

Test #51:

score: 10
Accepted
time: 6ms
memory: 84588kb

input:

1
501 500
317 393 166 174
219 415 120 143
11 28 409 436
197 470 35 76
401 460 189 236
201 230 45 94
211 461 319 359
211 220 246 255
283 343 81 125
211 258 121 162
261 270 350 376
210 226 405 411
449 477 131 167
360 464 161 204
35 416 237 247
85 408 272 306
105 437 163 194
110 267 167 196
17 237 482 ...

output:

YES
168 132 420 62 217 73 339 247 110 145 360 405 148 191 237 289 178 180 482 481 165 318 319 398 223 269 306 457 399 453 81 232 364 195 203 477 108 197 298 352 340 299 33 2 162 254 463 287 258 454 38 301 233 341 268 78 206 396 293 170 204 235 192 321 353 154 414 455 439 408 45 255 21 312 25 236 323...

result:

ok all is ok (1 test case)

Test #52:

score: 10
Accepted
time: 5ms
memory: 84588kb

input:

1
501 500
66 362 223 231
19 173 108 146
267 468 15 84
269 309 295 302
438 462 348 415
132 187 474 498
91 416 92 191
141 161 71 169
142 309 153 177
59 390 139 220
57 203 359 449
172 362 463 466
226 463 444 495
344 369 1 68
122 266 320 336
293 326 316 358
108 207 34 114
14 140 153 182
339 383 363 383
...

output:

YES
223 120 48 295 377 475 165 143 154 184 412 463 471 30 320 329 84 156 363 123 159 260 431 121 125 423 28 218 57 440 336 272 398 224 415 393 445 306 359 166 347 425 314 335 67 16 18 7 39 104 95 436 350 382 308 197 101 270 477 318 92 353 366 351 418 285 262 36 483 133 396 446 362 220 432 213 474 46...

result:

ok all is ok (1 test case)

Test #53:

score: 10
Accepted
time: 7ms
memory: 84456kb

input:

1
501 500
419 457 238 270
52 410 93 141
101 172 97 163
146 274 112 149
277 448 127 325
435 440 46 195
375 380 159 299
107 306 326 359
31 441 188 346
6 55 174 197
74 340 16 123
38 437 1 72
265 366 178 255
203 442 1 105
42 119 215 281
54 65 1 85
72 213 14 208
358 392 301 302
210 359 125 197
142 293 27...

output:

YES
238 93 102 112 273 140 247 326 293 174 61 25 205 47 230 39 151 301 141 272 211 388 144 66 378 249 319 70 148 375 4 135 448 434 1 443 294 18 317 255 444 27 69 321 420 265 234 49 439 158 198 131 417 397 430 75 362 307 337 412 414 92 366 282 324 427 128 170 173 74 331 30 445 342 437 407 178 308 446...

result:

ok all is ok (1 test case)

Test #54:

score: 10
Accepted
time: 8ms
memory: 84592kb

input:

1
501 500
153 365 163 163
123 153 196 196
123 282 30 33
282 361 105 110
85 361 466 471
85 126 290 290
43 126 8 9
43 273 423 425
273 357 101 101
142 357 62 63
142 499 336 341
22 499 493 495
22 408 125 127
54 408 124 129
54 355 85 88
315 355 113 116
60 315 198 200
60 309 37 42
309 369 53 57
95 369 144...

output:

YES
163 196 31 107 470 290 8 424 101 62 341 494 125 128 85 114 198 39 54 144 130 71 222 489 221 202 388 246 217 339 19 467 10 5 299 72 429 360 165 44 183 55 333 328 172 82 335 308 407 317 495 219 230 291 375 463 46 161 56 274 104 347 297 91 226 310 304 157 9 243 466 180 208 439 106 302 98 454 440 16...

result:

ok all is ok (1 test case)

Test #55:

score: 10
Accepted
time: 11ms
memory: 86504kb

input:

1
501 500
23 115 137 146
23 68 233 249
53 68 53 59
53 342 321 335
11 342 342 356
11 279 281 295
76 279 401 414
76 236 441 448
236 454 468 484
325 454 240 253
287 325 418 423
287 351 423 435
14 351 318 331
14 141 206 208
141 404 309 312
166 404 53 64
84 166 270 283
84 311 42 57
205 311 347 357
161 20...

output:

YES
138 242 53 329 351 291 411 441 475 248 418 428 322 206 309 59 278 48 352 263 37 249 220 54 448 75 376 24 333 357 454 389 73 393 302 456 88 117 253 449 159 419 87 149 104 193 30 494 306 458 266 8 165 421 414 74 26 183 124 392 148 388 315 287 135 284 493 367 400 179 349 96 455 406 412 252 386 182 ...

result:

ok all is ok (1 test case)

Test #56:

score: 10
Accepted
time: 8ms
memory: 84464kb

input:

1
501 500
106 202 458 492
36 202 180 230
36 327 245 293
133 327 448 463
133 174 211 216
174 256 73 89
256 278 82 113
111 278 242 292
111 194 15 42
194 480 188 211
432 480 473 500
161 432 191 193
55 161 290 320
7 55 347 390
7 28 17 25
28 418 188 197
408 418 48 91
389 408 52 69
297 389 459 486
268 297...

output:

YES
476 217 280 453 211 73 99 277 26 199 489 191 302 378 17 189 72 56 468 223 320 85 322 234 341 422 418 59 479 61 213 376 282 269 260 480 203 63 287 212 144 10 490 113 481 129 65 242 19 492 165 146 298 69 470 97 464 58 290 123 429 283 395 437 198 122 207 116 136 153 304 333 68 225 316 491 252 190 1...

result:

ok all is ok (1 test case)

Test #57:

score: 10
Accepted
time: 8ms
memory: 84592kb

input:

1
501 500
128 431 134 232
62 431 214 243
118 431 68 159
194 431 157 213
422 431 297 355
226 431 377 461
208 431 112 196
179 431 202 288
46 431 1 72
302 431 68 110
353 431 313 313
197 431 1 17
233 431 111 162
12 431 443 500
234 431 167 234
387 431 466 500
35 431 244 332
397 431 487 500
204 431 430 49...

output:

YES
202 215 132 179 328 440 167 260 41 87 313 5 137 474 207 475 300 488 464 18 254 384 7 121 339 60 421 77 33 494 36 52 198 43 438 31 168 495 62 255 275 24 131 445 442 473 341 175 123 111 352 476 8 194 63 399 344 373 46 57 222 312 400 53 187 264 477 219 433 409 82 39 345 269 274 372 320 333 308 85 2...

result:

ok all is ok (1 test case)

Test #58:

score: 10
Accepted
time: 6ms
memory: 84592kb

input:

1
501 500
22 209 135 163
22 127 290 314
22 45 167 197
22 333 178 195
22 275 131 163
22 346 137 139
22 382 177 202
22 48 126 154
22 253 405 440
22 415 466 492
22 168 112 119
22 252 445 465
22 337 46 68
22 98 170 192
22 87 314 338
22 448 473 488
22 93 276 287
22 259 459 488
22 77 194 222
22 277 208 21...

output:

YES
153 303 184 183 154 137 191 142 430 482 112 453 58 177 328 473 276 474 207 208 104 455 431 475 122 253 500 219 436 203 14 165 29 463 192 169 140 258 283 348 450 442 313 74 96 123 205 82 353 263 393 467 265 241 146 83 49 368 366 167 129 327 323 480 386 185 148 407 68 319 35 489 378 468 432 239 23...

result:

ok all is ok (1 test case)

Test #59:

score: 10
Accepted
time: 3ms
memory: 82544kb

input:

1
501 500
124 342 261 323
7 124 103 106
124 439 303 341
124 443 316 342
81 124 456 458
124 429 24 53
124 413 205 262
75 124 54 91
124 336 348 382
124 433 412 452
124 147 349 401
124 180 91 150
124 501 385 434
124 133 191 247
124 447 152 220
18 124 469 493
124 271 67 76
124 316 395 457
124 279 260 29...

output:

YES
302 103 318 319 456 39 241 71 363 432 385 125 415 226 199 469 67 438 275 346 374 54 313 179 376 440 213 478 143 457 265 479 280 354 122 36 89 321 30 190 82 335 408 152 373 453 222 131 205 377 309 238 114 433 345 132 81 406 204 198 468 160 351 398 142 170 177 64 144 323 69 21 359 365 337 20 186 1...

result:

ok all is ok (1 test case)

Test #60:

score: 10
Accepted
time: 6ms
memory: 84592kb

input:

1
501 500
233 402 267 276
144 233 313 315
156 233 23 33
233 266 9 15
19 233 297 310
233 324 106 116
233 493 402 402
233 323 357 372
16 233 142 147
134 233 448 455
171 233 164 164
37 233 150 159
233 245 387 397
233 432 229 230
233 272 275 276
145 233 188 201
109 233 166 172
233 482 476 477
233 464 24...

output:

YES
272 313 27 13 305 113 402 368 144 450 164 156 391 229 275 193 167 476 256 152 231 135 171 468 276 338 46 14 247 428 194 48 273 496 29 15 370 471 441 344 107 291 495 65 406 353 125 120 49 19 429 308 158 497 192 378 321 100 139 91 357 318 2 278 440 405 367 334 252 102 137 479 204 5 24 241 359 33 2...

result:

ok all is ok (1 test case)

Test #61:

score: 10
Accepted
time: 7ms
memory: 84592kb

input:

1
501 500
156 217 398 408
56 217 92 93
145 217 57 62
217 399 350 355
82 217 470 474
217 308 311 321
31 217 227 227
217 476 314 324
217 289 386 398
122 217 289 296
217 501 217 229
217 398 328 329
217 458 462 472
217 357 192 199
132 217 266 271
131 217 136 137
152 217 365 374
121 217 375 386
217 358 2...

output:

YES
403 92 58 352 470 317 227 320 395 289 225 328 466 197 268 136 369 380 270 263 350 112 341 87 100 416 46 135 196 338 35 300 459 161 479 81 434 312 49 219 9 311 256 340 119 218 51 111 461 22 314 362 417 386 375 351 398 221 293 418 258 142 247 309 149 273 406 327 354 93 378 373 27 175 66 107 332 43...

result:

ok all is ok (1 test case)

Test #62:

score: 10
Accepted
time: 8ms
memory: 82396kb

input:

20
26 25
5 23 23 25
10 13 7 11
2 11 19 21
11 24 5 9
1 6 12 14
6 24 24 25
9 24 8 8
18 22 22 23
10 17 9 13
10 21 20 24
2 26 16 16
8 17 3 6
3 12 3 6
4 16 17 21
10 15 7 11
3 6 9 10
11 19 15 19
4 22 1 4
23 24 4 6
14 19 1 1
8 16 17 20
10 20 12 15
10 11 24 25
7 17 11 14
3 25 11 13
26 25
1 16 13 13
1 12 5 5...

output:

YES
23 7 19 6 13 24 8 22 11 21 16 3 4 20 10 9 17 2 5 1 18 15 25 14 12 
YES
13 5 9 24 16 7 20 11 23 17 12 18 1 21 25 22 14 6 10 8 4 19 2 15 3 
YES
15 14 11 8 21 9 22 13 1 10 18 6 2 19 16 3 5 7 4 23 17 24 12 20 25 
YES
8 23 17 15 25 22 3 7 13 18 9 24 12 14 19 16 10 4 1 2 11 5 20 6 21 
YES
9 8 14 20 5 ...

result:

ok all is ok (20 test cases)

Test #63:

score: 10
Accepted
time: 8ms
memory: 82524kb

input:

20
26 25
11 17 10 12
11 13 10 10
1 11 25 25
6 11 1 1
11 25 8 9
3 11 22 22
5 11 4 5
11 24 20 20
2 11 1 3
10 11 19 19
7 11 21 22
11 12 4 6
11 22 16 17
11 21 16 16
11 16 12 13
11 14 18 19
9 11 24 24
4 11 11 11
8 11 4 4
11 20 7 8
11 19 7 9
11 26 14 14
11 15 23 25
11 23 1 2
11 18 13 15
26 25
6 25 19 20
6...

output:

YES
12 10 25 1 8 22 5 20 3 19 21 6 17 16 13 18 24 11 4 7 9 14 23 2 15 
YES
19 15 21 4 1 24 25 11 9 18 13 2 23 10 5 17 6 16 12 14 22 20 8 3 7 
YES
11 22 8 14 6 10 24 25 21 19 23 4 7 5 1 2 16 9 20 3 15 17 12 18 13 
YES
21 5 9 2 12 17 13 14 25 8 1 3 6 22 23 18 15 4 19 16 7 20 11 10 24 
YES
4 10 3 12 1 ...

result:

ok all is ok (20 test cases)

Test #64:

score: 10
Accepted
time: 3ms
memory: 84576kb

input:

20
26 25
6 13 4 4
1 9 5 5
5 16 22 25
18 26 16 16
6 20 6 8
3 8 1 3
6 23 21 23
6 25 16 21
3 15 19 20
11 23 20 21
2 17 6 8
17 23 17 21
6 16 14 18
5 24 23 25
4 12 1 4
21 23 11 11
14 22 18 19
4 8 3 8
7 15 2 2
1 7 8 13
15 26 9 13
2 3 6 9
10 26 9 11
7 19 23 25
20 22 12 17
26 25
17 23 12 15
8 23 12 12
3 23 ...

output:

YES
4 5 23 16 6 1 22 17 19 20 7 21 15 24 3 11 18 8 2 12 13 9 10 25 14 
YES
15 12 17 5 18 2 10 4 14 20 3 1 9 24 22 21 16 6 8 25 23 13 19 11 7 
YES
6 8 18 24 3 14 5 15 21 20 22 25 17 23 7 12 10 2 11 4 16 13 1 9 19 
YES
21 12 15 23 4 2 8 17 25 20 16 7 9 18 24 22 19 10 14 1 3 11 5 6 13 
YES
15 20 14 19 ...

result:

ok all is ok (20 test cases)

Test #65:

score: 10
Accepted
time: 7ms
memory: 84572kb

input:

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

output:

YES
2 4 6 7 10 1 8 5 9 3 
YES
9 10 5 3 8 2 4 1 6 7 
YES
4 2 6 7 9 1 8 3 5 10 
YES
10 4 1 9 6 5 8 7 3 2 
YES
5 9 8 1 6 7 3 10 2 4 
YES
9 1 6 2 8 3 5 4 10 7 
YES
9 1 10 6 7 4 8 5 2 3 
YES
8 7 6 1 4 9 2 10 3 5 
YES
5 2 9 7 3 4 10 1 6 8 
YES
10 4 1 9 6 7 8 2 3 5 
YES
5 8 7 3 4 2 1 9 6 10 
YES
3 7 6 8 4 ...

result:

ok all is ok (50 test cases)

Test #66:

score: 10
Accepted
time: 8ms
memory: 82520kb

input:

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

output:

YES
9 5 6 10 4 8 7 1 2 3 
YES
8 4 6 5 1 9 2 3 7 10 
YES
8 2 6 5 10 3 7 1 4 9 
YES
8 6 4 9 2 10 1 5 3 7 
YES
5 6 1 8 9 2 7 10 3 4 
YES
9 7 1 4 5 3 10 2 8 6 
YES
8 10 7 6 4 1 3 5 2 9 
YES
6 8 9 3 7 4 2 5 1 10 
YES
6 5 4 2 3 7 1 9 8 10 
YES
8 3 10 4 6 5 9 2 1 7 
YES
6 3 8 7 5 9 10 4 1 2 
YES
1 7 4 2 5 ...

result:

ok all is ok (50 test cases)

Test #67:

score: 0
Wrong Answer
time: 8ms
memory: 84404kb

input:

10
51 50
13 32 47 48
3 32 46 50
3 35 13 22
32 40 8 8
22 35 42 50
3 16 31 42
15 22 1 11
22 25 37 50
16 41 5 10
17 22 8 15
34 41 36 37
3 51 10 13
4 16 1 6
35 48 44 50
28 40 26 33
24 32 49 50
4 20 24 24
27 40 20 25
8 25 16 26
40 46 30 41
8 36 4 17
17 18 3 3
19 28 29 37
6 48 5 16
6 7 1 12
20 47 43 49
17...

output:

xd1
xd1
xd1
xd1
xd1
YES
21 46 4 41 10 25 12 23 18 31 13 1 26 30 45 11 34 27 3 9 14 19 5 17 20 28 36 35 24 47 38 16 39 33 15 8 7 43 37 29 32 42 22 48 2 44 49 40 6 50 
xd1
xd1
xd1
xd1

result:

wrong answer Token parameter [name=Yes/No] equals to "xd1", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #93:

score: 20
Accepted
time: 275ms
memory: 84968kb

input:

1000
500 500
100 331 2 8
162 182 272 276
133 415 393 397
144 176 499 500
64 273 47 55
37 463 424 428
96 481 127 127
115 341 333 336
79 95 246 248
266 473 473 476
117 140 113 120
112 309 323 330
251 438 39 45
22 339 275 285
83 474 264 266
185 212 282 291
377 425 25 31
42 436 351 357
35 69 173 182
159...

output:

YES
6 272 394 499 51 424 127 333 246 474 114 327 40 279 266 283 28 354 177 485 151 12 14 350 359 267 18 81 343 375 199 480 461 407 216 86 482 112 277 192 153 493 129 224 159 268 356 372 315 393 33 103 444 396 284 94 208 340 188 242 385 200 303 362 214 95 371 21 304 116 373 346 165 399 88 314 42 369 ...

result:

ok all is ok (1000 test cases)

Test #94:

score: 20
Accepted
time: 270ms
memory: 85100kb

input:

1000
500 500
263 445 23 34
78 313 146 154
230 479 442 449
30 422 402 413
203 491 298 313
211 353 266 276
336 449 412 428
39 200 291 315
333 344 15 30
77 227 472 475
166 435 90 115
338 471 223 236
237 287 203 213
226 457 17 32
7 179 441 454
130 447 344 359
5 302 376 383
75 329 423 424
76 386 172 190
...

output:

YES
29 146 442 407 307 267 417 311 25 472 103 223 204 28 441 351 376 423 181 487 164 185 374 302 239 111 345 70 431 321 372 149 143 184 316 464 395 415 340 236 333 209 460 268 79 373 3 82 432 466 142 495 289 290 251 8 291 85 416 334 16 327 300 92 77 119 394 455 213 398 40 320 341 386 113 253 457 444...

result:

ok all is ok (1000 test cases)

Test #95:

score: 20
Accepted
time: 282ms
memory: 89492kb

input:

100
5000 5000
1050 3257 3679 3683
1611 2666 4834 4845
452 3180 4411 4415
1500 4067 2424 2437
989 3394 3014 3023
3098 4437 4722 4727
1309 3218 1175 1177
4456 4719 3394 3404
3064 4235 533 549
2422 3362 1097 1104
3526 4419 4206 4219
1349 3646 4192 4200
889 3142 3836 3852
1429 2797 180 194
941 971 2333 ...

output:

YES
3679 4840 4411 2425 3021 4724 1175 3394 544 1102 4215 4196 3844 187 2341 3681 11 3939 4881 731 1638 4778 1179 4621 4902 4339 471 3647 2920 2227 3584 2028 2816 1005 1766 449 2921 1977 1046 3898 1378 2209 1272 650 1230 1989 3837 3936 255 3471 2070 3572 1573 140 4731 1795 1419 2380 4288 909 1505 20...

result:

ok all is ok (100 test cases)

Test #96:

score: 20
Accepted
time: 285ms
memory: 87336kb

input:

100
5000 5000
896 1568 2762 2764
896 3943 4810 4813
896 4703 1309 1311
698 896 3724 3727
896 4466 145 146
896 1510 3366 3367
896 3907 787 791
412 896 1161 1163
896 1144 2699 2702
896 4397 2012 2014
896 1197 486 487
896 1959 3032 3040
896 3782 4002 4010
896 4120 2053 2061
896 2848 1007 1016
29 896 29...

output:

YES
2762 4811 1309 3726 146 3366 788 1161 2701 2012 486 3035 4009 2058 1010 2918 694 511 2323 47 4535 1722 2994 4505 1153 4795 1203 3628 595 2286 238 3357 997 412 1970 1244 4320 1535 144 1316 167 1579 1743 2038 543 3811 1850 840 3110 1255 2270 4635 3835 4592 4782 4641 3534 265 1542 2805 2905 4902 25...

result:

ok all is ok (100 test cases)

Test #97:

score: 0
Wrong Answer
time: 318ms
memory: 96296kb

input:

10
50000 50000
16923 41334 36220 36274
3707 16923 25007 25485
16923 43183 18327 19460
3707 36130 39723 39849
3236 43183 43590 44645
33673 36130 25151 25263
40317 43183 17958 18364
9548 40317 5313 5322
29972 33673 38913 40387
16923 46964 13196 14120
16660 43183 40309 40886
3690 3707 18129 19025
40317...

output:

xd2
xd2
xd2
xd2
xd2
xd2
xd2
xd2
xd2
xd2

result:

wrong answer Token parameter [name=Yes/No] equals to "xd2", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Wrong Answer

Test #143:

score: 8
Accepted
time: 259ms
memory: 82280kb

input:

1000
251 500
1 2 280 287
2 3 251 256
3 4 249 249
4 5 252 253
5 6 252 256
6 7 250 250
7 8 254 261
8 9 245 256
9 10 123 127
10 11 45 49
11 12 122 128
12 13 164 167
13 14 153 156
14 15 210 217
15 16 53 64
16 17 205 208
17 18 136 149
18 19 132 135
19 20 24 27
20 21 45 51
21 22 21 30
22 23 5 7
23 24 178 ...

output:

YES
280 253 249 252 254 250 257 255 123 46 125 164 153 214 58 205 145 132 24 47 26 5 179 86 78 215 187 106 216 23 181 109 21 32 121 8 221 27 127 207 141 36 217 42 11 184 150 66 68 146 167 211 162 142 90 159 134 61 28 172 85 115 137 54 76 165 30 147 101 3 105 75 139 177 188 1 14 73 209 35 192 33 124 ...

result:

ok all is ok (1000 test cases)

Test #144:

score: 8
Accepted
time: 255ms
memory: 84584kb

input:

1000
351 500
1 2 62 69
2 3 225 227
3 4 160 166
4 5 172 177
5 6 118 120
6 7 35 42
7 8 92 100
8 9 82 87
9 10 222 230
10 11 234 239
11 12 141 145
12 13 213 217
13 14 110 116
14 15 154 157
15 16 280 280
16 17 243 250
17 18 124 132
18 19 20 29
19 20 328 329
20 21 41 48
21 22 189 192
22 23 241 249
23 24 4...

output:

YES
64 225 163 174 118 39 95 83 226 234 141 213 115 156 280 248 130 25 328 43 189 247 49 157 70 214 255 284 9 140 235 28 282 149 26 334 216 123 249 86 134 139 313 170 323 220 78 72 110 217 151 268 128 238 30 41 330 294 48 45 186 111 343 253 54 180 66 97 107 348 340 318 19 125 87 312 63 91 162 37 303...

result:

ok all is ok (1000 test cases)

Test #145:

score: 8
Accepted
time: 259ms
memory: 82528kb

input:

1000
251 500
1 2 175 184
2 3 74 76
3 4 134 143
4 5 63 69
5 6 18 19
6 7 258 258
7 8 216 221
8 9 157 163
9 10 224 229
10 11 220 227
11 12 115 115
12 13 187 189
13 14 209 216
14 15 1 4
15 16 10 10
16 17 82 83
17 18 75 84
18 19 146 148
19 20 233 238
20 21 80 87
21 22 134 136
22 23 59 59
23 24 228 238
24...

output:

YES
182 74 138 65 18 258 218 159 226 221 115 187 212 1 10 82 79 146 234 86 136 59 235 112 121 83 216 68 34 93 28 53 215 196 143 217 58 201 106 27 155 56 148 54 41 124 94 84 170 228 51 63 69 78 21 175 153 3 70 174 134 242 157 95 6 162 26 44 99 36 198 149 119 241 220 132 13 161 186 80 120 231 118 229 ...

result:

ok all is ok (1000 test cases)

Test #146:

score: 8
Accepted
time: 259ms
memory: 84576kb

input:

1000
151 500
1 2 198 198
2 3 165 167
3 4 1 10
4 5 121 125
5 6 114 117
6 7 131 136
7 8 134 141
8 9 97 103
9 10 90 94
10 11 133 135
11 12 118 123
12 13 51 60
13 14 139 147
14 15 61 61
15 16 46 49
16 17 33 40
17 18 62 62
18 19 70 76
19 20 65 69
20 21 114 122
21 22 1 1
22 23 71 71
23 24 5 5
24 25 2 5
25...

output:

YES
198 166 7 123 115 135 137 97 91 133 120 57 143 61 46 35 62 70 65 118 1 71 5 4 18 96 6 89 78 19 68 20 107 40 134 76 101 66 69 98 112 100 121 136 142 85 51 80 86 138 103 125 31 32 114 132 43 117 92 77 58 110 144 104 49 2 64 127 50 75 25 41 30 53 8 99 87 131 109 47 74 28 79 88 124 12 116 130 128 11...

result:

ok all is ok (1000 test cases)

Test #147:

score: 0
Wrong Answer
time: 502ms
memory: 179060kb

input:

1
250001 500000
1 2 232634 232778
2 3 439147 439210
3 4 242069 242195
4 5 123158 123260
5 6 404204 404219
6 7 148853 149029
7 8 128047 128105
8 9 241218 241219
9 10 396066 396078
10 11 431745 431863
11 12 265898 265945
12 13 358860 358915
13 14 154751 154864
14 15 346376 346465
15 16 251154 251293
1...

output:

xd2

result:

wrong answer Token parameter [name=Yes/No] equals to "xd2", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)

Subtask #9:

score: 0
Skipped

Dependency #7:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

0%