QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#288865 | #7866. Teleportation | ucup-team1001# | WA | 0ms | 3756kb | C++23 | 1.4kb | 2023-12-23 13:57:52 | 2023-12-23 13:57:52 |
Judging History
answer
/*
Author: haze
2023/12/23
13:34
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int (i) = (l); (i) <= (r); ++(i))
#define drep(i, r, l) for(int (i) = (r); (i) >= (l); --(i))
#define ll long long
#define LL __int128
using namespace std;
inline ll read() {
char ch = getchar();
ll s = 0;
bool w = 0;
while (!isdigit(ch)) {
if (ch == '-')w = 1;
ch = getchar();
}
while (isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
return w ? -s : s;
}
inline char rc() {
char ch = getchar();
while (1) {
if (ch >= '!' && ch <= '~')return ch;
ch = getchar();
}
}
template<class T1, class T2>
T1 min(T1 AA, T2 BB) { return AA > BB ? BB : AA; }
template<class T1, class T2>
T1 max(T1 AA, T2 BB) { return AA < BB ? BB : AA; }
const int itinf = 1e9;
const ll llinf = 4e18;
const int mod = 1000000007;
const int N = 500009;
int main() {
int n = read(), t = read();
vector<int>a(n * 2), dis(n * 2, itinf);
irep(i, 0, n - 1){
a[i] = read(), a[i + n] = a[i];
}
dis[0] = 0;
if(a[0] == 0){
dis[0] = 1, a[0] = 1;
}
irep(i, 0, n * 2 - 1){
if(i < n * 2 && i > a[0])dis[i] = min(dis[i], dis[i - 1] + 1);
if(i + a[i] < 2 * n)dis[i + a[i]] = min(dis[i] + 1, dis[i + a[i]]);
}
// irep(i, 0, n * 2 - 1)cerr << dis[i] <<' ';
cout << min(dis[t], dis[t + n]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
4 3 0 1 2 3
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
4 3 0 0 0 0
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
4 3 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
2 1 0 0
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3756kb
input:
300 25 182 9 13 211 258 132 27 42 218 200 271 258 164 121 8 84 29 195 141 290 110 0 272 93 142 134 140 32 232 99 162 199 297 287 212 29 182 53 61 98 116 282 75 245 230 165 22 4 179 89 274 231 46 299 248 208 200 285 221 50 221 199 294 241 195 138 22 204 113 100 132 276 158 146 238 178 100 94 131 157 ...
output:
13
result:
wrong answer 1st numbers differ - expected: '10', found: '13'