提出 #27359912


ソースコード 拡げる

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <math.h>
#include <climits>
typedef long long LL;
using namespace std;

int main()
{
    LL N = 0u;
    cin >> N;
    LL X = 0u;
    cin >> X;
    vector<LL> A;
    for (LL i = 0ULL; i < N; ++i)
    {
        LL a = 0u;
        cin >> a;
        A.emplace_back(a-1);
    }

    set<LL> knowsSecret;
    knowsSecret.insert(X-1);
    LL result = 0u;
    LL current = X-1;
    while (true)
    {
        if (knowsSecret.find(A[current]) == knowsSecret.end())
        {
            knowsSecret.insert(A[current]);
            current = A[current];
        }
        else
        {
            break;
        }
    }
    cout << knowsSecret.size() << endl;
}

提出情報

提出日時
問題 B - Takahashi's Secret
ユーザ wfalps
言語 C++ (GCC 9.2.1)
得点 200
コード長 829 Byte
結果 AC
実行時間 73 ms
メモリ 8800 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:8: warning: unused variable ‘result’ [-Wunused-variable]
   29 |     LL result = 0u;
      |        ^~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 2
AC × 26
セット名 テストケース
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
ケース名 結果 実行時間 メモリ
000.txt AC 7 ms 3576 KiB
001.txt AC 73 ms 8560 KiB
002.txt AC 33 ms 4220 KiB
003.txt AC 32 ms 4148 KiB
004.txt AC 72 ms 8736 KiB
005.txt AC 35 ms 4228 KiB
006.txt AC 50 ms 6252 KiB
007.txt AC 50 ms 6368 KiB
008.txt AC 34 ms 4324 KiB
009.txt AC 39 ms 5172 KiB
010.txt AC 35 ms 4324 KiB
011.txt AC 35 ms 4228 KiB
012.txt AC 27 ms 4224 KiB
013.txt AC 53 ms 6176 KiB
014.txt AC 52 ms 6252 KiB
015.txt AC 70 ms 8800 KiB
016.txt AC 27 ms 4320 KiB
017.txt AC 18 ms 3820 KiB
018.txt AC 16 ms 3788 KiB
019.txt AC 31 ms 4224 KiB
020.txt AC 29 ms 4320 KiB
021.txt AC 27 ms 4260 KiB
022.txt AC 34 ms 4324 KiB
023.txt AC 35 ms 4236 KiB
example0.txt AC 2 ms 3428 KiB
example1.txt AC 3 ms 3508 KiB