QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#508411 | #7866. Teleportation | emt | WA | 0ms | 3680kb | C++20 | 1.5kb | 2024-08-07 15:00:25 | 2024-08-07 15:00:26 |
Judging History
answer
// #pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
using i128 = __int128_t;
using u128 = __uint128_t;
#define int long long
#define mem(a, b) memset((a), (b), sizeof(a))
#define all(a) (a).begin(), (a).end()
#define lowbit(x) (-x) & x
#define debug cout<<"$"
#define ls u << 1
#define rs u << 1 | 1
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using pi = pair<int,int>;
using p3 = tuple<int,int,int>;
mt19937 rnd(time(0));
const int MOD = 1e9+7;
const ld eps = 1;
int qmi(int m, int k){int res = 1, t = m;while (k){if (k & 1) res = (res * t) % MOD;t = t * t % MOD;k >>= 1;}return res;}
const int N = 2e6 + 7;
const int inf = 1e18 + 7;
void solve()
{
int n,x;
cin>>n>>x;
vector<int> ans(n,inf);
// vector<int> len(n);
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
if(x==0) return cout<<"0\n",void();
priority_queue<p3,vector<p3>,greater<p3>> q1;
q1.push({1,0,1});
while(1)
{
auto [now,st,len] = q1.top();
q1.pop();
if(st==x) return cout<<now-len<<"\n",void();
q1.push({now+1,st,len+1});
q1.push({now+2,(st+len+a[st])%n,1});
}
}
signed main()
{
// freopen("test.in","r",stdin);
// freopen("test.in","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin>>T;
while (T--)
solve();
}
/*
1 2 7
3 5
4 6
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
4 3 0 1 2 3
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
4 3 0 0 0 0
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
4 3 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 1 0 0
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
2 1 1 1
output:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'