CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Counter
Sender:Rasse
Submission time:2024-11-27 16:34:12 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.01 sdetails
#27ACCEPTED0.02 sdetails

Code

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <climits>
#include <cmath>
#include <functional>
#include <type_traits>
#include <fstream>
#include <bitset>
#include <complex>
#include <iomanip>
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp> // gcc only
template<typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
 
#define int long long
using namespace std;
 
int p(int base, int power, int mod)
{
    if (power == 0)
        return 1;
    if (power % 2 == 0)
    {
        int r = p(base, power/2, mod);
        return (r*r) % mod;
    }
    else
        return (p(base, power-1, mod)*base) % mod;
}
 
int LCM(int a, int b)
{
    return (a / __gcd(a, b)) * b;
}
 
int mod = 1e9+7;
 
 
void solve()
{
    int n;
    cin >> n;

    vector<bool> vis(n+1, false);
    queue<pair<int, int>> moves;
    moves.push({0, 0});

    while (!moves.empty())
    {
        int num = moves.front().first;
        if (num == n)
        {
            cout << moves.front().second;
            return;
        }

        if (num <= n-11 && !vis[num+11])
        {
            moves.push({num+11, moves.front().second+1});
            vis[num+11] = true;
        }
        if (num >= 2 && !vis[num-2])
        {
            moves.push({num-2, moves.front().second+1});
            vis[num-2] = true;
        }
        moves.pop();
    }

    cout << -1;
    
} 
 
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int t = 1;
 
    //cin >> t;
 
    for (int i = 0; i < t; i++)
    {
        solve();
        //cout.flush();
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
0

correct output
0

user output
0

Test 2

Verdict: ACCEPTED

input
1

correct output
-1

user output
-1

Test 3

Verdict: ACCEPTED

input
2

correct output
-1

user output
-1

Test 4

Verdict: ACCEPTED

input
10

correct output
-1

user output
-1

Test 5

Verdict: ACCEPTED

input
11

correct output
1

user output
1

Test 6

Verdict: ACCEPTED

input
23

correct output
8

user output
8

Test 7

Verdict: ACCEPTED

input
90

correct output
20

user output
20

Test 8

Verdict: ACCEPTED

input
8

correct output
-1

user output
-1

Test 9

Verdict: ACCEPTED

input
88

correct output
8

user output
8

Test 10

Verdict: ACCEPTED

input
2

correct output
-1

user output
-1

Test 11

Verdict: ACCEPTED

input
62

correct output
8

user output
8

Test 12

Verdict: ACCEPTED

input
53

correct output
6

user output
6

Test 13

Verdict: ACCEPTED

input
55

correct output
5

user output
5

Test 14

Verdict: ACCEPTED

input
84

correct output
10

user output
10

Test 15

Verdict: ACCEPTED

input
72

correct output
16

user output
16

Test 16

Verdict: ACCEPTED

input
71

correct output
10

user output
10

Test 17

Verdict: ACCEPTED

input
16

correct output
5

user output
5

Test 18

Verdict: ACCEPTED

input
86

correct output
9

user output
9

Test 19

Verdict: ACCEPTED

input
81

correct output
18

user output
18

Test 20

Verdict: ACCEPTED

input
19

correct output
10

user output
10

Test 21

Verdict: ACCEPTED

input
21

correct output
9

user output
9

Test 22

Verdict: ACCEPTED

input
249

correct output
25

user output
25

Test 23

Verdict: ACCEPTED

input
835

correct output
83

user output
83

Test 24

Verdict: ACCEPTED

input
94

correct output
18

user output
18

Test 25

Verdict: ACCEPTED

input
10000

correct output
915

user output
915

Test 26

Verdict: ACCEPTED

input
100000

correct output
9098

user output
9098

Test 27

Verdict: ACCEPTED

input
1000000

correct output
90915

user output
90915