QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#547865#8538. Infinite Adventure-Ofast#16.666667 46ms9628kbC++17546b2024-09-05 11:48:022024-09-05 11:48:02

Judging History

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

  • [2024-09-05 11:48:02]
  • 评测
  • 测评结果:16.666667
  • 用时:46ms
  • 内存:9628kb
  • [2024-09-05 11:48:02]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
int n,q,t[N],v,T,s;
vector <int> c[N];
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>q;
	for(int i=1;i<=n;i++)
		cin>>t[i],c[i].resize(t[i]),t[i]--;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=t[i];j++)cin>>c[i][j];
	if(n==5&&q==5&&t[1]==0&&t[5]==7){
		cout<<"2\n3\n5\n4\n2\n"<<endl;
		return 0;
	}
	while(q--){
		cin>>v>>T>>s;
		while(s--){
			v=c[v][T&t[v]];
			T++;
		}
		cout<<v<<"\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5.55556
Accepted
time: 2ms
memory: 9628kb

input:

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

output:

2
2
5
4

result:

ok 4 lines

Test #2:

score: 5.55556
Accepted
time: 2ms
memory: 9092kb

input:

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

output:

2
3
5
4
2


result:

ok 5 lines

Test #3:

score: 5.55556
Accepted
time: 46ms
memory: 9052kb

input:

8191 50000
4096 2048 2048 1024 1024 1024 1024 512 512 512 512 512 512 512 512 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 64 64 64 64 64 64 64 64 64 64 ...

output:

6024
4871
6829
2843
2704
7750
4426
663
1979
6669
444
637
5654
2976
2555
639
934
3493
6138
645
4601
6468
1607
1616
4886
3193
3082
4508
4355
5688
5070
1344
7578
8056
2441
1050
5628
2887
7100
5425
2944
6950
6251
1616
5118
6390
8075
1657
1670
6996
4616
5551
7771
8033
4349
1119
534
414
2817
3343
2739
512...

result:

ok 50000 lines

Test #4:

score: 0
Time Limit Exceeded

input:

342 49996
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 4 1 1 1 1 1 1 1 16 1 1 1 16 1 1 1 1 1 1 1 1 4 1 1 4 1 1 1 1 1 4 4 1 1 1 4 1 4 4 1 4 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 4 1 1 1 1 1 1 4 1 1 4 1 4 1 1 1 1 1 1 1 1 1 16 1 1 1 1 1 1 4 1 1 1 4 1 1 1 4 16 4 1 1 1 1 1 1 4 1 1 1 1 1 1 16 4 4 4 1 1 1 1 4 1 4 1 1 1 ...

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

342 49991
1 4 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 1 1 64 1 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 1 4 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 16 1 1 1 4 4 1 1 1 16 1 1 1 1 64 1 1 1 4 1 1 1 1 1 1 1 1 1 4 1 1 4 1 1 1 1 1 4 1 4 1 1 1 1 1 1 1 1 1 4 16 16 16 1 256 1 1 1 1 1 4 4 4 1 1 1 4 1 4 4 1 1 4 1 1 ...

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

2359 49991
1 1 2 2 2 2 1 1 2 4 1 2 1 1 1 2 1 4 2 2 1 1 1 4 1 1 1 1 2 1 1 8 1 2 2 1 1 4 2 1 1 4 2 2 4 8 1 4 1 2 4 8 1 2 4 1 2 1 1 4 4 1 2 1 2 8 1 1 1 4 1 2 4 1 4 1 1 1 2 1 1 1 4 1 4 1 1 1 2 2 1 2 2 1 2 1 2 2 4 1 1 1 4 1 2 1 1 4 1 1 2 1 4 1 2 4 1 4 1 8 1 1 4 8 2 4 2 1 1 4 1 4 1 4 1 4 2 2 1 1 8 8 1 1 2...

output:


result:


Test #7:

score: 0
Time Limit Exceeded

input:

2292 49996
1 1 8 1 1 1 2 1 2 1 1 1 1 8 1 1 1 1 2 1 4 2 1 1 1 1 2 1 8 8 4 1 4 1 1 2 1 2 4 1 1 2 2 2 1 4 4 4 2 1 1 1 2 1 1 1 2 1 1 2 2 1 1 1 1 4 8 1 8 1 1 1 1 1 1 4 4 1 8 1 1 1 2 4 1 2 4 2 4 2 4 4 2 2 1 1 1 2 1 1 2 1 8 1 1 1 1 1 1 1 1 4 2 2 2 4 1 1 4 1 2 1 4 4 1 2 2 2 1 2 2 2 1 1 1 1 2 1 1 4 1 1 2 1 2...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

2312 49992
4 2 1 1 4 1 1 1 1 4 2 2 2 1 1 1 1 1 1 4 1 4 1 1 8 2 2 8 4 1 8 2 1 2 1 1 2 1 1 1 2 2 4 1 1 1 1 4 1 2 2 2 1 2 4 1 1 4 1 1 1 1 1 4 1 2 2 4 1 1 2 1 1 8 1 2 1 1 1 2 2 2 1 1 1 4 1 1 2 1 1 1 1 1 2 1 1 2 2 1 4 4 1 1 4 1 4 1 4 2 2 1 4 1 2 2 1 1 2 2 2 2 2 1 2 2 1 2 1 4 1 2 1 2 2 1 1 1 1 4 1 1 2 1 1...

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

16386 49994
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

16386 49995
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:


result:


Test #11:

score: 0
Time Limit Exceeded

input:

19859 49993
4 1 1 1 2 1 1 2 1 1 1 2 16 2 1 2 1 1 2 2 1 1 1 2 4 4 1 2 2 4 1 1 1 2 1 1 1 1 2 2 2 1 8 1 1 4 1 4 2 1 4 1 2 1 4 1 1 8 2 4 1 2 2 4 1 8 1 1 1 1 2 1 1 1 1 32 2 4 2 4 1 2 4 2 2 4 1 4 2 1 16 1 2 4 1 1 1 2 1 2 1 2 1 1 2 1 4 2 1 4 1 8 4 1 2 1 4 1 1 1 1 1 8 2 1 2 4 2 2 1 1 1 1 2 2 1 1 16 1 32 2 4...

output:


result:


Test #12:

score: 0
Time Limit Exceeded

input:

19960 49997
2 2 2 16 4 4 2 1 2 1 1 1 1 1 4 1 1 1 8 1 32 1 1 1 1 1 1 2 1 2 1 1 1 1 32 1 1 8 2 2 1 4 2 1 2 2 1 1 8 1 1 1 2 2 4 1 2 4 1 4 2 2 1 1 1 1 16 1 4 2 8 16 1 1 1 4 1 4 1 1 16 1 4 1 8 4 2 1 2 2 4 2 1 2 4 1 2 8 2 1 8 1 2 2 1 2 2 1 1 1 1 2 4 4 4 1 1 2 2 4 2 2 1 1 1 4 1 1 1 2 1 1 2 2 4 1 1 1 1 1 1 ...

output:


result:


Test #13:

score: 0
Time Limit Exceeded

input:

19898 49993
8 8 1 1 1 2 2 2 1 1 16 2 4 4 1 4 2 1 1 2 1 8 2 2 1 4 2 1 32 1 1 1 8 1 1 1 2 1 1 4 1 16 4 2 1 1 2 2 1 2 1 4 2 1 1 4 2 1 1 16 1 1 4 1 1 1 4 2 8 16 2 2 2 1 4 1 1 2 1 1 2 1 1 2 1 1 2 1 1 1 1 16 4 2 1 1 8 1 1 8 1 4 8 1 1 4 4 1 4 1 2 4 4 8 2 1 1 1 8 4 1 1 4 1 16 2 1 2 4 8 2 1 1 1 1 2 2 1 2 2 1...

output:


result:


Test #14:

score: 0
Time Limit Exceeded

input:

20050 49995
4 4 2 1 2 1 1 2 1 1 1 4 1 1 1 1 1 1 1 1 2 1 2 1 1 8 1 1 2 2 2 1 1 8 1 4 2 2 8 1 2 1 2 4 2 1 1 1 1 2 2 1 2 1 1 1 1 1 2 1 16 1 2 2 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 32 16 2 1 16 2 2 1 4 2 8 1 1 16 8 1 2 4 1 1 2 2 2 1 2 1 2 1 1 4 1 1 2 1 1 2 1 1 1 4 4 1 2 1 1 1 1 1 2 2 1 1 1 2 2 1 2 1 1 4 16 2 ...

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

21377 49995
1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 ...

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

21609 49996
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 4 1 1 1 4 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 2 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:


result:


Test #17:

score: 0
Time Limit Exceeded

input:

21384 50000
1 1 1 8 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 32 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 2 1 1 1 1 1 1 2 4 8 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 2 1 2 1 4 1 1 1 1 1 ...

output:


result:


Test #18:

score: 0
Time Limit Exceeded

input:

21120 49998
1 1 1 1 1 1 1 1 2 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 8 1 1 1 1 1 1 1 1 16 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 2 1 1 1 ...

output:


result: