QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625213#7866. TeleportationnoyapoyoWA 0ms3692kbC++141.2kb2024-10-09 17:57:282024-10-09 17:57:28

Judging History

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

  • [2024-10-09 17:57:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-10-09 17:57:28]
  • 提交

answer

#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
using namespace std;
ll n, x;
const ll mxn = 1e5 + 5;
ll arr[mxn];
set <ll> v;
const ll INF = 1e9;
ll solve(ll i, ll j)
{
    if (i == j)
    {
        v.insert(i * n + j);
        return 0;
    }
    else
    {
        ll idx_1 = ((i + arr[i] + 1) % n) * n + j;
        ll idx_2 = ((i + arr[i]) % n) * n + j;
        ll ans_1, ans_2;
        v.insert(i * n + j);
        if (v.find(idx_1) == v.end())
        {
            ans_1 = solve((i + arr[i] + 1) % n, j) + 2;
        }
        else
        {
            ans_1 = INF;
            //v.insert(idx_1);
        }
        if (v.find(idx_2) == v.end())
        {
            ans_2 = solve((i + arr[i]) % n, j);
        }
        else
        {
            ans_2 = INF;
            //v.insert(idx_2);
        }
        //ll ans = INF;
        ll ans_3 = j - arr[i] + 1;
        return min(min(ans_1, ans_3),ans_2);
    }
}
int main()
{
    cin >> n >> x;
    for (ll i = 0 ; i < n ; i++)
    {
        cin >> arr[i];
    }
    ll ans = 0;
    ans = solve(0, x);
    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3692kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

2 1
1 1

output:

0

result:

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