QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21224#2810. SpeedrunQingyu21 152ms3712kbC++204.0kb2022-03-03 19:57:112023-01-17 10:50:26

Judging History

你现在查看的是测评时间为 2023-01-17 10:50:26 的历史记录

  • [2024-06-05 09:12:03]
  • 管理员手动重测本题所有提交记录
  • 测评结果:72
  • 用时:36ms
  • 内存:4032kb
  • [2024-05-20 18:51:06]
  • 管理员手动重测本题所有提交记录
  • 测评结果:72
  • 用时:36ms
  • 内存:4120kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-17 10:50:26]
  • 评测
  • 测评结果:21
  • 用时:152ms
  • 内存:3712kb
  • [2022-03-03 19:57:11]
  • 提交

speedrun

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 */
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
typedef vector<pi> vpi;
 
//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}
 
#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define outfl(x){cout << x << endl;return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& p){is >> p.first >> p.second;return is;}
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& p){os <<"" << p.first << " " << p.second << ""; return os;}
void usaco(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
    freopen(FOUT, "w", stdout);
}
template<typename T>
void read(vector<T>& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
template<typename T>
vector<T>UNQ(vector<T>a){
    vector<T>ans;
    for(T t:a)
        if(ans.empty() || t!=ans.back())
            ans.push_back(t);
    return ans;
}
 
 
 
#include "speedrun.h"
 
vvi g;
vi ord;
void set1(int i,int x){
    for(int j=0; j<10; j++)
        if(x&(1<<j))
            setHint(i,j+1,1);
}
void set2(int i,int x){
    for(int j=0; j<10; j++)
        if(x&(1<<j))
            setHint(i,j+10+1,1);
}
 
void dfsp(int src,int par){
    if(par!=-1)
        set2(src,par);
    ord.pb(src);
    for(int nbr:g[src])
        if(nbr!=par)
            dfsp(nbr,src);
}
void assignHints(int subtask, int n, int A[], int B[]) {
    g.resize(n+1);
    for(int i=1; i<n; i++){
        g[A[i]].pb(B[i]);
        g[B[i]].pb(A[i]);
    }
 
    setHintLen(21);
    dfsp(1,-1);
 
    set2(1,ord.back());
    for(int i=0; i<n; i++){
        set1(ord[i],ord[(i+1)%ord.size()]);
    }
    for(int i=2; i<=n; i++)
        setHint(i,21,g[i].size()==1);
}
 
int get(int ix){
    int ans=0;
    for(int i=0; i<10; i++)
        if(getHint(1+i+10*ix))
            ans+=(1<<i);
    return ans;
}
 
stack<int>nxt;
vector<bool>vis;
void dfs(int src,int par){
    int cnxt=get(0),cprv=get(1);
    vis[src]=1;
    if(getHint(21) && !vis[cnxt])
        nxt.push(cnxt);
 
    while(!getHint(21)){
        bool ok=0;
        while(nxt.size() && !vis[nxt.top()] && goTo(nxt.top())){
            int t=nxt.top();
            nxt.pop();
            dfs(t,src);
            ok=1;
        }
        if(!vis[cnxt] && goTo(cnxt)) {
            dfs(cnxt, src);
            if(!nxt.size())
                break;
            cnxt=nxt.top();
            ok=1;
        }
        if(!ok)break;
    }
    if(!vis[cprv] && goTo(cprv))
        dfs(cprv,src);
    if(par!=-1)
        goTo(par);
}
 
void speedrun(int subtask, int N, int start) {
    vis.resize(N+1);
    dfs(start,-1);
    bool ok=1;
}
/*
5
1 2
1 3
3 4
3 5
 
5
1 2
1 3
1 4
1 5
 
7
1 2
1 3
2 4
2 5
3 6
3 7
 
18
1 2
1 3
2 4
2 5
3 6
3 7
5 8
6 9
6 10
1 11
3 12
12 13
8 14
14 15
15 16
16 17
1 18
 */

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 21
Accepted

Test #1:

score: 21
Accepted
time: 85ms
memory: 3584kb

input:

1
1 1000
1 119
1 453
1 454
2 59
3 113
3 657
3 824
4 494
5 33
5 550
5 937
6 287
7 222
7 577
7 742
8 626
9 896
10 204
11 638
12 305
12 552
12 791
13 246
14 840
15 95
15 316
15 772
16 109
16 551
16 846
17 581
18 142
19 601
19 744
19 977
20 361
20 404
20 845
21 245
21 410
21 518
22 351
23 971
24 497
24 ...

output:

1 1 21
1 2 119 11 1
1 2 295 11 1
1 2 295 12 1
1 2 295 13 1
1 2 295 15 1
1 2 295 16 1
1 2 295 17 1
1 2 735 11 1
1 2 735 12 1
1 2 735 13 1
1 2 735 16 1
1 2 735 19 1
1 2 785 11 1
1 2 785 12 1
1 2 785 13 1
1 2 785 14 1
1 2 785 15 1
1 2 785 17 1
1 2 785 18 1
1 2 785 20 1
1 2 164 11 1
1 2 164 15 1
1 2 164...

input:

2
1 1000 500
1
1
0
0
0
0
0
1
0
0
1
0
0
1
1
1
1
1
0
0
0
0
1
0
1
0
1
1
1
0
0
1
0
0
0
1
0
1
1
1
1
1
0
1
1
1
0
1
1
1
0
1
1
0
1
1
0
1
0
0
1
0
1
1
1
1
1
0
1
1
1
0
0
0
1
0
1
1
0
0
0
1
0
1
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
1
0
0
1
1
1
1
1
0
0
0
0
0
1
0
0
0
0
0
1
1
0
0
1
0
1
1
0
0
0
1
0
1
0
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 131
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 ...

result:

ok OK

Test #2:

score: 21
Accepted
time: 152ms
memory: 3624kb

input:

1
1 1000
1 723
1 992
2 372
2 542
3 692
4 692
5 693
5 807
6 390
6 829
7 692
8 692
9 692
10 692
11 692
12 692
13 692
14 692
15 228
15 844
16 692
17 419
17 663
18 692
19 105
19 930
20 692
21 324
21 974
22 692
23 366
23 525
24 692
25 195
25 641
26 692
27 434
27 734
28 692
29 692
30 332
30 540
31 692
32 ...

output:

1 1 21
1 2 723 11 1
1 2 289 11 1
1 2 289 12 1
1 2 289 15 1
1 2 289 17 1
1 2 289 18 1
1 2 289 20 1
1 2 129 11 1
1 2 129 16 1
1 2 129 19 1
1 2 115 11 1
1 2 115 18 1
1 2 395 11 1
1 2 395 12 1
1 2 395 15 1
1 2 395 16 1
1 2 395 17 1
1 2 794 11 1
1 2 794 12 1
1 2 794 14 1
1 2 794 18 1
1 2 794 19 1
1 2 953...

input:

2
1 1000 856
1
0
1
1
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
1
0
1
1
0
1
1
1
0
0
0
0
1
0
0
0
0
0
1
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
0
1
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
0
1
0
0
0
1
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
0
0
1
0
0
1
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
0
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 692
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 ...

result:

ok OK

Test #3:

score: 21
Accepted
time: 105ms
memory: 3632kb

input:

1
1 1000
1 14
1 139
1 817
1 975
2 840
2 993
3 207
4 367
4 847
4 977
5 18
6 9
6 667
7 135
7 389
7 474
7 595
8 296
8 535
9 970
10 337
11 648
11 899
12 266
12 414
13 207
13 922
14 620
14 936
15 44
16 984
17 459
17 825
17 902
18 511
18 535
19 872
20 522
20 717
21 234
21 426
21 515
21 609
22 488
22 869
2...

output:

1 1 21
1 2 14 11 1
1 2 620 12 1
1 2 620 13 1
1 2 620 14 1
1 2 49 13 1
1 2 49 14 1
1 2 49 16 1
1 2 49 17 1
1 2 49 20 1
1 2 936 12 1
1 2 936 13 1
1 2 936 14 1
1 2 991 14 1
1 2 991 16 1
1 2 991 18 1
1 2 991 19 1
1 2 991 20 1
1 2 139 11 1
1 2 166 11 1
1 2 166 12 1
1 2 166 14 1
1 2 166 18 1
1 2 738 11 1
...

input:

2
1 1000 938
1
1
0
0
0
1
1
1
0
0
0
1
0
1
0
1
0
1
0
0
0
0
1
0
0
0
1
0
1
0
1
1
0
0
1
0
1
0
1
0
1
1
1
0
0
1
1
1
1
1
0
1
0
1
1
0
1
1
0
0
0
1
1
1
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
0
0
1
0
1
0
1
1
0
1
1
1
0
1
0
1
0
0
1
0
1
0
0
1
0
0
0
1
0
1
0
1
1
0
0
0
1
0
1
0
1
1
0
1
0
0
1
0
1
0
0
1
1
1
1
1
0
1
1
1
0
0
0
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 227
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 ...

result:

ok OK

Test #4:

score: 21
Accepted
time: 86ms
memory: 3656kb

input:

1
1 1000
1 504
1 638
1 792
1 941
2 133
3 664
4 188
4 341
4 685
5 385
5 561
5 881
6 961
7 413
7 584
7 906
7 907
8 662
9 267
9 320
9 606
9 627
10 795
10 926
11 45
11 88
12 926
13 202
13 435
13 621
13 872
14 570
14 598
14 656
14 821
15 880
16 26
16 171
16 765
16 910
17 347
18 980
19 419
20 74
20 294
20...

output:

1 1 21
1 2 504 11 1
1 2 638 11 1
1 2 681 12 1
1 2 681 13 1
1 2 681 14 1
1 2 681 15 1
1 2 681 16 1
1 2 681 17 1
1 2 681 20 1
1 2 451 11 1
1 2 451 14 1
1 2 451 16 1
1 2 451 18 1
1 2 451 20 1
1 2 466 11 1
1 2 466 14 1
1 2 466 16 1
1 2 466 18 1
1 2 466 20 1
1 2 391 12 1
1 2 391 15 1
1 2 391 17 1
1 2 391...

input:

2
1 1000 84
1
1
0
0
1
1
1
1
1
0
1
0
0
0
1
0
1
0
0
0
0
0
1
1
1
1
0
1
0
0
0
0
1
0
0
1
0
1
0
1
0
0
0
1
1
1
0
1
1
0
1
0
1
0
0
0
0
1
0
0
1
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
0
0
1
1
0
1
1
1
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
1
0
0
1
0
1
0
1
0
0
0
0
1
0
0
1
0
1
1
0
0
0
1
0
0
1
1
1
1
1
0
0
0
1
1
0
1
1
1
0
1
1
0
...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 499
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 ...

result:

ok OK

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 3580kb

input:

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

output:

1 1 21

input:

2
2 1000 651
1
0
1
1
1
1
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 253
2 3 401

result:

wrong answer Solution didn't visit every node

Subtask #3:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 3ms
memory: 3712kb

input:

1
3 1000
1 20
1 569
2 69
2 72
3 510
3 811
4 278
4 994
5 890
5 918
6 97
6 577
7 11
7 791
8 138
8 653
9 219
9 539
10 22
10 151
11 527
12 195
12 420
13 187
13 293
14 265
14 476
15 594
15 988
16 424
16 881
17 407
17 613
18 178
18 471
19 400
19 896
20 95
21 221
21 949
22 624
23 247
23 361
24 140
24 169
2...

output:

1 1 21

input:

2
3 1000 986
1
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
0
0
1
1
1
0

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 2 11
2 2 12
2 2 13
2 2 14
2 2 15
2 2 16
2 2 17
2 2 18
2 2 19
2 2 20
2 2 21
2 2 21
2 3 553

result:

wrong answer Solution didn't visit every node

Subtask #4:

score: 0
Interactor1 Dangerous Syscalls

Test #10:

score: 0
Interactor1 Dangerous Syscalls

input:

1
4 1000
1 103
1 881
2 195
2 740
3 224
4 558
5 749
5 788
6 189
7 221
8 362
9 267
9 547
10 205
10 813
10 926
11 23
12 687
13 225
14 366
14 768
15 58
15 156
15 869
16 79
16 225
17 61
17 437
18 500
18 534
18 768
18 989
19 300
20 909
21 970
22 245
22 425
23 528
23 669
23 809
23 890
24 121
24 778
25 845
...

output:

1 1 21
1 2 103 11 1
1 2 560 11 1
1 2 560 12 1
1 2 560 13 1
1 2 560 16 1
1 2 560 17 1
1 2 803 11 1
1 2 803 12 1
1 2 803 13 1
1 2 803 16 1
1 2 803 17 1
1 2 534 11 1
1 2 534 12 1
1 2 534 16 1
1 2 534 19 1
1 2 534 20 1
1 2 18 12 1
1 2 18 13 1
1 2 18 15 1
1 2 18 20 1
1 2 500 12 1
1 2 500 15 1
1 2 768 12 ...

input:


output:


result:


Subtask #5:

score: 0
Interactor1 Dangerous Syscalls

Test #16:

score: 0
Interactor1 Dangerous Syscalls

input:

1
5 1000
1 296
1 974
2 414
3 777
4 158
4 918
5 535
5 799
5 952
6 290
7 17
7 420
8 223
9 600
10 743
11 189
11 239
11 530
11 619
12 27
12 451
13 580
14 165
15 552
15 753
16 883
16 936
17 292
17 398
17 904
18 355
18 678
19 807
20 577
21 392
21 744
22 600
23 582
23 717
23 915
24 70
24 254
24 492
25 115
...

output:

1 1 21
1 2 296 11 1
1 2 496 14 1
1 2 496 16 1
1 2 496 19 1
1 2 945 15 1
1 2 945 16 1
1 2 945 17 1
1 2 945 18 1
1 2 945 19 1
1 2 768 14 1
1 2 768 16 1
1 2 768 19 1
1 2 39 19 1
1 2 39 20 1
1 2 873 14 1
1 2 873 16 1
1 2 873 19 1
1 2 109 11 1
1 2 109 14 1
1 2 109 16 1
1 2 109 17 1
1 2 109 19 1
1 2 109 2...

input:


output:


result: