ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215237 | #2726. 8.3t4 | erican | 0 | 0ms | 1428kb | C++11 | 1.8kb | 2024-11-27 19:45:18 | 2024-11-27 23:36:51 |
answer
/* Erica N */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define endl '\n'
#define ull unsigned long long
#define pii pair<int, int>
#define ps second
#define pf first
#define itn int
#define rd read()
int read(){
int xx = 0, ff = 1;char ch = getchar();
while (ch < '0' || ch > '9') {if (ch == '-')ff = -1; ch = getchar();}
while (ch >= '0' && ch <= '9')xx = xx * 10 + (ch - '0'), ch = getchar();
return xx * ff;
}
// void write(int out) {
// if (out < 0)
// putchar('-'), out = -out;
// if (out > 9)
// write(out / 10);
// putchar(out % 10 + '0');
// }
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() { cerr << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cerr << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
const int N = 3e5 + 5;
const int INF = 1e18;
const int M = 1e7;
const int MOD = 1e9 + 7;
int n,a[N];
int f[N][340];
int dfs(int x,int k){
if(x>n)return 0;
return f[x][k]=dfs(x+a[x]+k,k)+1;
}
signed main() {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
n=rd;
int sq=sqrt(n);
for(int i=1;i<=n;i++){
a[i]=rd;
}
for(int k=1;k<=sq;k++){
for(int i=1;i<=n;i++){
if(!f[i][k])dfs(i,k);
}
}
int m=rd;
while(m--){
int p=rd,k=rd;
if(k>n){
int cur=0;
while(p<=n){
cur++;
p=p+a[p]+k;
}
cout<<cur<<endl;
}else{
cout<<f[p][k]<<endl;
}
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1428kb
input:
100 5 6 12 22 23 21 22 7 30 5 22 22 29 30 30 10 7 17 25 24 1 16 17 30 3 19 7 27 14 20 28 5 22 23 13 ...
output:
0 7 5 0 0 0 0 4 0 0 0 0 0 0 5 4 0 0 0 5 5 0 4 5 3 0 0 5 4 0 0 0 0 0 0 6 0 5 0 4 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '3', found: '0'
Test #2:
score: 0
Time Limit Exceeded
input:
100000 25 29 13 9 17 27 2 5 20 4 27 25 5 24 17 13 13 14 3 13 4 24 19 9 21 20 14 17 9 11 13 9 5 24 20...
output:
result:
Test #3:
score: 0
Time Limit Exceeded
input:
100000 16 18 28 7 16 2 30 19 30 28 17 8 8 16 16 3 11 19 29 7 9 27 6 27 27 28 29 3 18 27 5 29 14 15 2...
output:
result:
Test #4:
score: 0
Time Limit Exceeded
input:
100000 29 30 15 26 1 29 1 4 12 22 12 4 9 27 20 29 21 8 29 27 11 5 13 7 20 15 5 15 10 1 30 28 10 30 3...
output:
result:
Test #5:
score: 0
Time Limit Exceeded
input:
100000 30 25 29 4 13 25 14 15 21 20 8 4 17 16 13 8 10 17 21 10 14 13 9 26 28 14 28 13 29 10 28 2 3 1...
output:
result:
Test #6:
score: 0
Time Limit Exceeded
input:
100000 3 1 9 1 7 6 10 9 5 10 6 5 5 8 2 8 10 1 9 4 4 3 6 3 1 9 5 2 7 8 1 3 8 6 1 8 3 1 1 10 8 4 2 8 5...
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
100000 19 6 20 1 19 14 23 14 23 3 9 1 14 19 22 21 4 26 2 20 16 9 27 20 23 2 19 5 13 18 6 11 17 13 9 ...
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
100000 3 16 18 2 10 29 27 26 12 11 15 12 29 16 2 8 14 4 28 13 21 13 2 24 4 9 16 14 4 27 27 15 18 13 ...
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
100000 82 65 27 36 67 74 9 74 35 72 97 28 57 78 88 66 89 20 30 50 2 1 19 8 97 4 47 37 6 73 22 31 64 ...
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...