QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625219#7866. TeleportationnoyapoyoWA 1ms3720kbC++141.2kb2024-10-09 17:59:152024-10-09 17:59:16

Judging History

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

  • [2024-10-09 17:59:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-10-09 17:59:15]
  • 提交

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) + 1;
        }
        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: 1ms
memory: 3584kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3600kb

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:

-245

result:

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