QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#547864#8538. Infinite Adventure-Ofast#11.111111 1ms3740kbC++17518b2024-09-05 11:46:262024-09-05 11:46:26

Judging History

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

  • [2024-09-05 11:46:26]
  • 评测
  • 测评结果:11.111111
  • 用时:1ms
  • 内存:3740kb
  • [2024-09-05 11:46:26]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e3+10;
int n,q,t[N],c[N][N],v,T,s;

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],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: 0ms
memory: 3672kb

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: 0ms
memory: 3740kb

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: 0
Wrong Answer
time: 1ms
memory: 3652kb

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:

0
0
0

result:

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

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
Wrong Answer
time: 0ms
memory: 3588kb

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:

0

result:

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

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

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:

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

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 3736kb

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:

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

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 3536kb

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:

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

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

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:

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

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

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:

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

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 3676kb

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:

0
0
0
0
1
0
1

result:

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

Test #13:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

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:

0
0
0

result:

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

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 3720kb

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:

0

result:

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

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 3728kb

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:

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

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

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:

1

result:

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

Test #17:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

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:

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

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

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:

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