buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
#include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
int main() {
queue<int> que;
queue<int> q;
ll n, k, fro = 0;
cin >> n >> k;
ll a[n], b[n];
fill(b, b + n, 0);
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
que.push(0);
b[0] = 1;
int i = 0;
while ... | #include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
int main() {
queue<int> que;
queue<int> q;
ll n, k, fro = 0;
cin >> n >> k;
ll a[n], b[n];
fill(b, b + n, 0);
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
que.push(0);
b[0] = 1;
int i = 0;
while ... | [["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 291 |
# = int(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
next = 1
List = [-1]*N
for i in range(K):
if List[next-1] == -1:
List[next-1] = i
next = A[next-1]
else:
lo... | # = int(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
next = 1
List = [-1]*N
for i in range(K):
if List[next-1] == -1:
List[next-1] = i
next = A[next-1]
else:
lo... | [["-", 31, 23, 0, 657, 12, 23, 0, 657, 17, 72], ["-", 31, 23, 0, 657, 12, 23, 0, 657, 12, 612], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 25]] | 5 | 131 |
N,K = map(int,input().split())
As = list(map(int,input().split()))
towns = [0]*N
route = [0]
pre = 0
i = 0
towns[0] = 1
for _ in range(N):
i = As[i]-1
if towns[i]>0:
pre = route.index(i)
route = route[pre:]
break
route.append(i)
towns[i] = 1
mod = len(route)
print(route[(K-pre)%m... | N,K = map(int,input().split())
As = list(map(int,input().split()))
towns = [0]*N
route = [0]
pre = 0
i = 0
towns[0] = 1
for _ in range(K):
i = As[i]-1
if towns[i]>0:
pre = route.index(i)
route = route[pre:]
break
route.append(i)
towns[i] = 1
mod = len(route)
print(route[(K-pre)%m... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 130 |
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
#define pi 3.14159265358979
template <class T> bool chmax(T &a, const ... | #include "bits/stdc++.h"
using namespace std;
using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
#define pi 3.14159265358979
template <class T> bool chmax(T &a, const ... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 687 |
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define printa(x, n) ... | /*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, m, n) for (ll i = (m); i < (n); i++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i--)
#define printa(x, n) ... | [["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13]] | 1 | 352 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
A_dict = {i:a for i,a in enumerate(A,1)}
History = [1]
History_set = {1}
now = 1
for _ in range(N):
now = A_dict[now]
if now not in History_set:
History.append(now)
History_set.add(now)
else:
break
#print(History,now)... | N,K = map(int,input().split())
A = list(map(int,input().split()))
A_dict = {i:a for i,a in enumerate(A,1)}
History = [1]
History_set = {1}
now = 1
for i in range(N):
now = A_dict[now]
if now not in History_set:
History.append(now)
History_set.add(now)
else:
break
#print(History,now)... | [["-", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 156 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | [["-", 64, 1, 0, 16, 12, 2, 63, 118, 17, 131], ["-", 64, 1, 0, 16, 12, 2, 63, 118, 119, 120], ["-", 64, 1, 0, 16, 12, 2, 3, 4, 0, 24], ["-", 64, 1, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 64, 1, 0, 16, 12, 69, 341, 342, 0, 70], ["+", 64, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 64, 1, 0, 16, 12, 69, 341, 342, 0, 73]] | 1 | 350 |
#include <cassert>
#include <ccomplex>
#include <cctype>
#include <cerrno>
#include <cfenv>
#include <cfloat>
#include <cinttypes>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstdbool>
#include <cstddef>
#include <cstdint>
... | #include <cassert>
#include <ccomplex>
#include <cctype>
#include <cerrno>
#include <cfenv>
#include <cfloat>
#include <cinttypes>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstdbool>
#include <cstddef>
#include <cstdint>
... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 70], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 73]] | 1 | 1,139 |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
int n = sc.nextInt();
long k = sc.nextLong();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt() - 1;
}
int cnt = 0;
int p =... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
int n = sc.nextInt();
long k = sc.nextLong();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt() - 1;
}
int cnt = 0;
int p =... | [["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 12, 499]] | 3 | 346 |
n,k = map(int, input().split())
a = list(map(int, input().strip().split()))
for i in range(len(a)):
a[i] -= 1
visited = [-1] * n
now = 0
visited[0] = 0
pre_roop = 0
pos = 0
i = 1
r = 1
while i < k:
next = a[now]
#print('roop:',i,now+1,next+1)
if visited[next] >= 0:
r = i-visited[next]
... | n,k = map(int, input().split())
a = list(map(int, input().strip().split()))
for i in range(len(a)):
a[i] -= 1
visited = [-1] * n
now = 0
visited[0] = 0
pre_roop = 0
pos = 0
i = 1
r = 1
while i <= k:
next = a[now]
#print('roop:',i,now+1,next+1)
if visited[next] >= 0:
r = i-visited[next]
... | [["-", 36, 36, 0, 656, 0, 52, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 667, 19], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]] | 5 | 187 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#defin... | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#defin... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 501 |
def main(N, K, A):
i = 0 # 現在地
lst_memo = []
set_memo = set([])
while i not in set_memo:
lst_memo.append(i)
set_memo.add(i)
i = A[i] - 1 # pythonは一つずれる
key = lst_memo.index(i)
if K <= key:
print(lst_memo[K - 1] + 1)
else:
roop = lst_memo[key:]
... | def main(N, K, A):
i = 0 # 現在地
lst_memo = []
set_memo = set([])
while i not in set_memo:
lst_memo.append(i)
set_memo.add(i)
i = A[i] - 1 # pythonは一つずれる
key = lst_memo.index(i)
if K < key:
print(lst_memo[K] + 1)
else:
roop = lst_memo[key:]
... | [["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 18], ["-", 3, 4, 0, 657, 31, 206, 206, 657, 17, 33], ["-", 3, 4, 0, 657, 31, 206, 206, 657, 12, 612], ["-", 3, 4, 0, 657, 31, 206, 206, 657, 31, 22], ["-", 3, 4, 0, 657, 31, 206, 206, 657, 17, 72]] | 5 | 157 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, ans;
int64_t num = 0;
int64_t K, T;
cin >> N >> K;
int A[N + 1], B[N + 1];
for (int i = 1; i < N + 1; i++)
cin >> A[i];
for (int i = 1; i < N + 1; i++)
B[i] = 0;
int i = 1;
while (B[A[i]] == 0 && num < K) {
B[A[i]] = num;
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, ans;
int64_t num = 1;
int64_t K, T;
cin >> N >> K;
int A[N + 1], B[N + 1];
for (int i = 1; i < N + 1; i++)
cin >> A[i];
for (int i = 1; i < N + 1; i++)
B[i] = 0;
int i = 1;
while (B[A[i]] == 0 && num < K) {
B[A[i]] = num;
... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13]] | 1 | 214 |
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
temp = An[i]
if check[temp-1] == 1:
dup = temp
break
root.append(temp)
... | from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
temp = An[i]
if check[temp-1] == 1:
dup = temp
break
root.append(temp)
... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 180 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
now = a[now-1]
step += 1
if is_visited[now-1] == 0:
is_visited[now-1] = 1
else:
ind = visited.index(now)
loop = visited[ind:]
tmp ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
now = a[now-1]
step += 1
if is_visited[now-1] == 0:
is_visited[now-1] = 1
visited.append(now)
else:
ind = visited.index(now)
loop ... | [["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 128 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[1]
di={}
di[1]=1
for i in a:
b=a[l[-1]-1]
if b in di:
x=b
break
l.append(b)
di[b]=1
t1=0
for j in l:
if j==x:
break
else:
aa+=1
t2=len(l)-t1
if k<=t1:
print(l[k])
else:
aa=(k-t1)%t2
... | n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[1]
di={}
di[1]=1
for i in a:
b=a[l[-1]-1]
if b in di:
x=b
break
l.append(b)
di[b]=1
t1=0
for j in l:
if j==x:
break
else:
t1+=1
t2=len(l)-t1
if k<=t1:
print(l[k])
else:
aa=(k-t1)%t2
... | [["-", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22]] | 5 | 145 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low, high, i) for (i = low; i < high; i++)
#define forrev(high, low, i) for (i = high; i >= low; i--)
#define all(v) v.begin(), v.end()
#de... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low, high, i) for (i = low; i < high; i++)
#define forrev(high, low, i) for (i = high; i >= low; i--)
#define all(v) v.begin(), v.end()
#de... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 990 |
n,k = list(map(int,input().split()))
A = list(map(int,input().split()))
tour=[0]
visited=[0]*n
visited[0]=1
next_town = 0
flag=False
for i in range(n):
next_town=A[next_town]-1
if i+1==k:
flag = True
ans = next_town
break
if next_town==0:
first_roop_idx = 0
break
... | n,k = list(map(int,input().split()))
A = list(map(int,input().split()))
tour=[0]
visited=[0]*n
visited[0]=1
next_town = 0
flag=False
for i in range(n):
next_town=A[next_town]-1
if i+1==k:
flag = True
ans = next_town
break
if next_town==0:
first_roop_idx = 0
break
... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 201 |
#include <bits/stdc++.h>
using namespace std;
vector<int> vec, ans;
vector<bool> vis;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, res1, res2, res;
long long k;
cin >> n >> k;
vec.resize(n + 3);
vis.resize(n + 3);
for (int i = 1; i <= n; i++)
cin >> vec[i];
if (k ... | #include <bits/stdc++.h>
using namespace std;
vector<int> vec, ans;
vector<bool> vis;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, res1, res2, res;
long long k;
cin >> n >> k;
vec.resize(n + 3);
vis.resize(n + 3);
for (int i = 1; i <= n; i++)
cin >> vec[i];
if (k ... | [["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 0, 35], ["-", 64, 9, 0, 52, 15, 339, 51, 27, 28, 22], ["+", 64, 9, 0, 52, 15, 339, 51, 27, 28, 22]] | 1 | 265 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public final class Main {
public static void main(String[] args) {
final Scanner in =
new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int n = in.nextInt();
long k = in.nextLong();... |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public final class Main {
public static void main(String[] args) {
final Scanner in =
new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int n = in.nextInt();
long k = in.nextLong();... | [["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]] | 3 | 332 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int64_t K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
vector<bool> check1(N, false);
int now = 0, cnt1 = 0, cnt2 = 0;
while (true) {
if (check1[now] == false) {
c... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int64_t K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
vector<bool> check1(N, false);
int now = 0, cnt1 = 0, cnt2 = 0;
while (true) {
if (check1[now] == false) {
c... | [["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 256 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
set<int> p;
p.insert(1);
vector<int> a, b;
long long int n, k, l, w = 1, s;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
a.push_back(j);
}
if (n < k) {
for (int i = 1; i < k + 1; i++) {
... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
set<int> p;
p.insert(1);
vector<int> a, b;
long long int n, k, l, w = 1, s;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
a.push_back(j);
}
if (n < k) {
for (int i = 1; i < k + 1; i++) {
... | [["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 258 |
n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1, map(int, input().split())))
s = {0}
loop = [0]
while a[loop[-1]] not in s:
loop.append(a[loop[-1]])
s.add(loop[-1])
idx = loop.index(a[loop[-1]])
if k <= len(loop):
print(loop[k]+1)
else:
print(loop[(k - idx)% (len(loop) - idx)... | n,k = map(int, input().split())
a = list(map(lambda x : int(x) -1, map(int, input().split())))
s = {0}
loop = [0]
while a[loop[-1]] not in s:
loop.append(a[loop[-1]])
s.add(loop[-1])
idx = loop.index(a[loop[-1]])
if k < len(loop):
print(loop[k]+1)
else:
print(loop[(k - idx)% (len(loop) - idx) ... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 150 |
#include <bits/stdc++.h>
using namespace std;
#define BOUND 27182818284
#define MAT 2
typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;
ll MOD = 1000000007;
const ll INF = (1ll << 60);
const int INFint = (1 << 30);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) fo... | #include <bits/stdc++.h>
using namespace std;
#define BOUND 27182818284
#define MAT 2
typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;
ll MOD = 1000000007;
const ll INF = (1ll << 60);
const int INFint = (1 << 30);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) fo... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 2,383 |
n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
visit = {0}
tmp = 0
a_list = [0]
ans = True
for i in range(k):
tmp = a[tmp]
if tmp in visit:
left = a_list.index(tmp)
ans = False
print(a[left + (k - left) % (i + 1 - left)] + 1)
break
else:
vi... | n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
visit = {0}
tmp = 0
a_list = [0]
ans = True
for i in range(k):
tmp = a[tmp]
if tmp in visit:
left = a_list.index(tmp)
ans = False
print(a_list[left + (k - left) % (i + 1 - left)] + 1)
break
else:
... | [["-", 0, 652, 3, 4, 0, 657, 31, 206, 51, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 51, 22]] | 5 | 129 |
#include <iostream>
#include <queue>
using namespace std;
// bool isCircular(node *head);
struct node {
int val;
node *next;
};
bool isCircular(node *head) {
// An empty linked list is circular
if (head == NULL)
return true;
// Next of head
node *node = head->next;
// This loop would stope in bot... | #include <iostream>
#include <queue>
using namespace std;
// bool isCircular(node *head);
struct node {
int val;
node *next;
};
bool isCircular(node *head) {
// An empty linked list is circular
if (head == NULL)
return true;
// Next of head
node *node = head->next;
// This loop would stope in bot... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72]] | 1 | 444 |
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll... | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 54, 55, 0, 56, 49, 185, 54, 55, 0, 24], ["-", 0, 56, 49, 185, 54, 55, 0, 56, 39, 78], ["-", 54, 55, 0, 56, 49, 185, 54, 55, 0, 21], ["-", 54, 55, 0, 56, 49, 185, 54, 55, 0, 25]] | 1 | 326 |
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll... | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 3, 4, 0, 16, 12, 23, 0, 16, 17, 72], ["-", 3, 4, 0, 16, 12, 23, 0, 16, 12, 13]] | 1 | 326 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, goal, pla = 1;
int64_t K, KK;
cin >> N >> K;
int arr[N];
map<int, int> mp;
int cnt = 0;
int tele;
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
while (K > 0) {
if (!(mp.count(pla))) {
mp[pla] = cnt;
pla = arr[pla... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, goal, pla = 1;
int64_t K, KK;
cin >> N >> K;
KK = K;
int arr[N];
map<int, int> mp;
int cnt = 0;
int tele;
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
while (K > 0) {
if (!(mp.count(pla))) {
mp[pla] = cnt;
pla... | [["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22]] | 1 | 179 |
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typed... | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typed... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 467 |
from collections import defaultdict
n,k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
w = [1]
y = defaultdict(lambda: 0)
y[1] = 1
flag = 0
zen = 0
for i in range(k):
# print(s,a[s-1])
if(y[a[s-1]] == 1):
# print("w",w,a[s-1])
flag = 1
if(a[s-1] == 1):
break
else:
for j in range(... | from collections import defaultdict
n,k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
w = [1]
y = defaultdict(lambda: 0)
y[1] = 1
flag = 0
zen = 0
for i in range(k):
# print(s,a[s-1])
if(y[a[s-1]] == 1):
# print("w",w,a[s-1])
flag = 1
if(a[s-1] == 1):
break
else:
for j in range(... | [["-", 0, 662, 12, 206, 206, 663, 0, 657, 17, 33], ["-", 0, 662, 12, 206, 206, 663, 0, 657, 12, 612]] | 5 | 204 |
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
Visit = [False for i in range(n+1)]
loop_st,loop_end,loop_len = 0,0,0
st = 1
releki = []
loop_list = []
for i in range(10000000000000):
if Visit[st] == True:
loop_key = st
loop_st = releki.index(loop_key)
loop_end = len(r... | n,k = map(int,input().split())
A = [int(i) for i in input().split()]
Visit = [False for i in range(n+1)]
loop_st,loop_end,loop_len = 0,0,0
st = 1
releki = []
loop_list = []
for i in range(10000000000000):
if Visit[st] == True:
loop_key = st
loop_st = releki.index(loop_key)
loop_end = len(r... | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22]] | 5 | 166 |
b0=input().split()
towns=int(b0[0])
k=int(b0[1])
al=[int(i)-1 for i in input().split()]
rt=[-1 for x in range(towns)]
rt[0]=0
now=0
for x in range(1,300000):
now=al[now]
if rt[now]!=-1:
stp=x
break
else:
rt[now]=x
ll=stp-rt[now]
k2=k-rt[now]
if k<ll:
print(rt.index(k)+1)
else:
print(rt.ind... | b0=input().split()
towns=int(b0[0])
k=int(b0[1])
al=[int(i)-1 for i in input().split()]
rt=[-1 for x in range(towns)]
rt[0]=0
now=0
for x in range(1,300000000):
now=al[now]
if rt[now]!=-1:
stp=x
break
else:
rt[now]=x
ll=stp-rt[now]
k2=k-rt[now]
if k<rt[now]:
print(rt.index(k)+1)
else:
print... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 0, 656, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 206, 0, 73]... | 5 | 158 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] =... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] =... | [["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13]] | 1 | 370 |
N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=2*N:
s=1
for i in range(K):
s=A[s-1]
print(s)
else:
s=1
S={1}
iloop=1
while A[s-1] not in S:
S.add(A[s-1])
s=A[s-1]
iloop=iloop+1
p=s
loop=0
while A[s-1] != p:
lo... | N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=N:
s=1
for i in range(K):
s=A[s-1]
print(s)
else:
s=1
S={1}
iloop=1
while A[s-1] not in S:
S.add(A[s-1])
s=A[s-1]
iloop=iloop+1
p=s
loop=1
while A[s-1] != p:
loop... | [["-", 0, 656, 0, 57, 15, 666, 0, 657, 31, 612], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 48], ["-", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 178 |
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main(n, k, a):
ck=[-1]*n
tak=0
c=0
ck[0]=c
for i in range(n):
c+=1
tak=a[tak]-1
if ck[tak]!=-1:
loop=c-ck[tak]
lps=ck[tak]
break
ck[tak... | #!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main(n, k, a):
ck=[-1]*n
tak=0
c=0
ck[0]=c
for i in range(n):
c+=1
tak=a[tak]-1
if ck[tak]!=-1:
loop=c-ck[tak]
lps=ck[tak]
break
ck[tak... | [["+", 0, 7, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 0, 657, 31, 657, 31, 23, 0, 657, 31, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 164 |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0), ios::sync_with_stdio(false);
int64_t n, k;
cin >> n >> k;
vector<int> v(n + 1);
for (int64_t i = 1; i <= n; ++i) {
cin >> v.at(i);
}
vector<bool> mp(n + 1, false);
mp.at(1) = true;
vector<int64_t> cnt(n + 1, 0);
int64_t i = ... | #include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0), ios::sync_with_stdio(false);
int64_t n, k;
cin >> n >> k;
vector<int> v(n + 1);
for (int64_t i = 1; i <= n; ++i) {
cin >> v.at(i);
}
vector<bool> mp(n + 1, false);
mp.at(1) = true;
vector<int64_t> cnt(n + 1, 0);
int64_t i = ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 248 |
#include <bits/stdc++.h>
using namespace std;
const int mN = 200200;
int a[mN], nodes[mN];
int pos[mN];
int main() {
int n;
long long k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
int cnt = 0, start = 0, length = 1;
memset(pos, -1, sizeof(pos));
for (int u = 1;; u = a[u]) {
if (pos... | #include <bits/stdc++.h>
using namespace std;
const int mN = 200200;
int a[mN], nodes[mN];
int pos[mN];
int main() {
int n;
long long k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
int cnt = 0, start = 0, length = 1;
memset(pos, -1, sizeof(pos));
for (int u = 1;; u = a[u]) {
if (pos... | [["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 209 |
N, K = map(int,input().split())
A = list(map(int,input().split()))
count = 0
i = 1
position = 1
position_list = [1]
position_history = [0] * N
start_loop = 0
def last():
k = (K - start_loop) % (count - start_loop)
print(position_list[start_loop+k])
while i > 0:
position = A[position-1]
position_history[positi... | N, K = map(int,input().split())
A = list(map(int,input().split()))
count = 0
i = 1
position = 1
position_list = [1]
position_history = [0] * N
start_loop = 0
def last():
k = (K - start_loop) % (count - start_loop)
print(position_list[start_loop+k])
while i > 0:
position = A[position-1]
position_history[positi... | [["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]] | 5 | 153 |
import math
from collections import defaultdict
def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1 for _ in range(N)]
visited[0] = 0
current = 0
th = -1
per_loop = -1
for i in range(1, N+1):
current = A[current] - 1
if visi... | import math
from collections import defaultdict
def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1 for _ in range(N)]
visited[0] = 0
current = 0
th = -1
per_loop = -1
for i in range(1, N+1):
current = A[current] - 1
if visi... | [["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612]] | 5 | 183 |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include... | #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include... | [["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 1,059 |
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
memo = {}
i = a[0] - 1
memo[a[0]] = 1
count = 2
while !memo.has_key?(a[i]) do
memo[a[i]] = count
i = a[i]-1
count += 1
end
before_cycle_count = memo[a[i]] - 1
ans = memo.to_a
if before_cycle_count >= k then
puts ans[k-1][... | n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
memo = {}
i = a[0] - 1
memo[a[0]] = 1
count = 2
while !memo.has_key?(a[i]) do
memo[a[i]] = count
i = a[i]-1
count += 1
end
before_cycle_count = memo[a[i]]
ans = memo.to_a
if before_cycle_count >= k then
puts ans[k-1][0]
e... | [["-", 36, 36, 0, 493, 0, 662, 12, 738, 17, 33], ["-", 36, 36, 0, 493, 0, 662, 12, 738, 12, 612], ["+", 12, 738, 31, 738, 12, 739, 0, 738, 17, 72], ["+", 12, 738, 31, 738, 12, 739, 0, 738, 12, 612]] | 4 | 155 |
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
long long int n, k;
map<long long int, long long int> dic;
cin >> n >> k;
long long int temp;
long long int dbl; //ダブり
vector<long long int> a;
for (int i = 0; i < n; i++) {
cin >> temp;
a.pu... | #include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
long long int n, k;
map<long long int, long long int> dic;
cin >> n >> k;
long long int temp;
long long int dbl; //ダブり
vector<long long int> a;
for (int i = 0; i < n; i++) {
cin >> temp;
a.pu... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 323 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
const ll MAX = 50;
ll A[200005];
ll B[2000... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
const ll MAX = 61;
ll A[200005];
ll B[2000... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 238 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pi... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pi... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 639 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 333 |
#
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,default... | #
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,default... | [["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]] | 5 | 526 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ll n, k, a[200005] = {}, visitedTurn[200005];
cin >> n >> k;
for (ll i = 1; i <= n; i++) {
cin >> a[i];
visitedTurn[i] = -1;
}
visitedTurn[1] = 0;
ll townNumber = 1, loopNumber = 1, teleportNumber = 0, previousTown = 1... | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ll n, k, a[200005] = {}, visitedTurn[200005];
cin >> n >> k;
for (ll i = 1; i <= n; i++) {
cin >> a[i];
visitedTurn[i] = -1;
}
visitedTurn[1] = 0;
ll townNumber = 1, loopNumber = 1, teleportNumber = 0, previousTown = 1... | [["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]] | 1 | 215 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
if visit[pos]==0:
move.append(pos)
else:
roop.append(pos)
visit[pos] += 1
pos = a[pos] - 1
if len(move)>K:
print(move[K]+1)
else:
print(roop[(K-(len(... | N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
if visit[pos]==0:
move.append(pos)
else:
roop.append(pos)
visit[pos] += 1
pos = A[pos] - 1
if len(move)>K:
print(move[K]+1)
else:
print(roop[(K-(len(... | [["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22]] | 5 | 142 |
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
# combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import it... | # import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
# combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import it... | [["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47]] | 5 | 201 |
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostream> //入出力
#include <iter... | #include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostream> //入出力
#include <iter... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 606 |
N, K = map(int, input().split())
A_list = [int(a) for a in input().split()]
# print(N, K)
# print(A_list)
keiro = [1]
visit_town = [0]*N
town = 1
c = 1
while True:
visit_town[town - 1] = c
c += 1
town = A_list[town - 1]
# print('town', town)
if len(keiro) > 1 and visit_town[town-1] != 0:
... | N, K = map(int, input().split())
A_list = [int(a) for a in input().split()]
# print(N, K)
# print(A_list)
keiro = [1]
visit_town = [0]*N
town = 1
c = 1
while True:
visit_town[town - 1] = c
c += 1
town = A_list[town - 1]
# print('town', town)
if len(keiro) > 1 and visit_town[town-1] != 0:
... | [["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22]] | 5 | 199 |
def main():
N,K=map(int,input().split())
A=list(map(int,input().split()))
pos=set()
pos.add(0)
i=0
traversal=[0]
start=0
nodes=[1]
while(start<K):
position=A[i]-1
if position in pos:
break
traversal.append(position)
pos.add(position)
... | def main():
N,K=map(int,input().split())
A=list(map(int,input().split()))
pos=set()
pos.add(0)
i=0
traversal=[0]
start=0
nodes=[1]
while(start<K):
position=A[i]-1
if position in pos:
break
traversal.append(position)
pos.add(position)
... | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 206, 206, 206, 51, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 206, 0, 73]] | 5 | 174 |
def main():
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
# N = 2*(10**4)
# K = 10**18
# A = [i+2 for i in range(N)]
# A[-1] = 1
# print(A)
visited = [0]
visited_set = set([0])
now = 0
ind = 0
my_appe... | def main():
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
# N = 2*(10**4)
# K = 10**18
# A = [i+2 for i in range(N)]
# A[-1] = 1
# print(A)
visited = [0]
visited_set = set([0])
now = 0
ind = 0
my_appe... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 158 |
N ,K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]
C = {}
C[0] = 0
cnt = 0
jdg = 0
q = 0
while jdg == 0:
i = A[q]-1
q = i
if q in C:
l = C[q]
#print(q,l)
break
cnt += 1
B.append(i)
C[i] = cnt
r = cnt+1
#print(q)
#print(B)
#print(C)
#print(l)
#pr... | N ,K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]
C = {}
C[0] = 0
cnt = 0
jdg = 0
q = 0
while jdg == 0:
i = A[q]-1
q = i
if q in C:
l = C[q]
#print(q,l)
break
cnt += 1
B.append(i)
C[i] = cnt
r = cnt+1
#print(q)
#print(B)
#print(C)
#print(l)
#pr... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 162 |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long LL;
int T[200001];
bool vis[200001];
int ans, mulai, selesai;
vector<int> d;
LL K;
void dfs(int nod) {
vis[nod] = 1;
d.pb(nod);
if (K == 0) {
ans = nod;
return;
}
if (!vis[T[nod]])
K--, dfs(T[nod]);
else {
... | #include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long LL;
int T[200001];
bool vis[200001];
int ans, mulai, selesai;
vector<int> d;
LL K;
void dfs(int nod) {
vis[nod] = 1;
d.pb(nod);
if (K == 0) {
ans = nod;
return;
}
if (!vis[T[nod]])
K--, dfs(T[nod]);
else {
... | [["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]] | 1 | 294 |
#include <iostream>
#include <map>
#include <set>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll N, K;
cin >> N >> K;
map<ll, ll> mp;
for (ll i = 1; i <= N; i++) {
ll A;
cin >> A;
mp[i] = A;
}
set<ll> se;
vector<ll> vc;
ll cur = 1;
while (true) {
if (... | #include <iostream>
#include <map>
#include <set>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll N, K;
cin >> N >> K;
map<ll, ll> mp;
for (ll i = 1; i <= N; i++) {
ll A;
cin >> A;
mp[i] = A;
}
set<ll> se;
vector<ll> vc;
ll cur = 1;
while (true) {
if (... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 216 |
import sys
n,k=map(int,input().split())
alist=list(map(int,input().split()))
vislist=[1]
visset={1}
loopflag=True
endflag=False
donek=0
ima=1
while loopflag:
ima=alist[ima-1]
if ima in visset:
loopflag=False
if ima == alist[ima-1]:
endflag=True
else:
vislist.append(ima)... | import sys
n,k=map(int,input().split())
alist=list(map(int,input().split()))
vislist=[1]
visset={1}
loopflag=True
endflag=False
donek=0
ima=1
while loopflag:
ima=alist[ima-1]
if ima in visset:
loopflag=False
if ima == alist[ima-1]:
endflag=True
else:
vislist.append(ima)... | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 652, 3, 4, 0, 206, 206, 664, 17, 33], ["+", 0, 652, 3, 4, 0, 206, 206, 664, 28, 612]] | 5 | 186 |
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
int main() {
ll n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int d[n] = {};
int cnt = 0;
int temp = 0;
while (d[temp] =... | #include <algorithm>
#include <iostream>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
int main() {
ll n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int d[n] = {};
int cnt = 0;
int temp = 0;
while (d[temp] =... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 193 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
v = 0
li = [v]
set_ = {v}
while True:
nxt_v = a[v]
if nxt_v not in set_:
li.append(nxt_v)
set_.add(nxt_v)
v = nxt_v
else:
start = nxt_v
break
for i in range(len(li... | n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
v = 0
li = [v]
set_ = {v}
while True:
nxt_v = a[v]
if nxt_v not in set_:
li.append(nxt_v)
set_.add(nxt_v)
v = nxt_v
else:
start = nxt_v
break
for i in range(len(li)... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 167 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
long long tbl[2 * 100000] = {0}; // 何番目に訪れた?
int main() {
int n;
unsigned long long k;
int tmp;
cin >> n >> k;
cin.ignore();
for (int i = 0; i < n; i++) {
cin >> tmp;
--tmp;
a.push_back(tmp);
}
cin.ignore();
// Nまでだった... | #include <bits/stdc++.h>
using namespace std;
vector<long long> a;
long long tbl[2 * 100000] = {0}; // 何番目に訪れた?
int main() {
int n;
unsigned long long k;
int tmp;
cin >> n >> k;
cin.ignore();
for (int i = 0; i < n; i++) {
cin >> tmp;
--tmp;
a.push_back(tmp);
}
cin.ignore();
// Nまでだった... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]] | 1 | 312 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define MAX_N 200000
int lst_a[MAX_N];
int is_reach[MAX_N];
int lst_place[MAX_N];
int main() {
int N;
ll K;
cin >> N >> K;
rep(i, N) cin >> lst_a[i];
rep(i, N) lst_a[i] -=... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define MAX_N 200000
int lst_a[MAX_N];
int is_reach[MAX_N];
int lst_place[MAX_N];
int main() {
int N;
ll K;
cin >> N >> K;
rep(i, N) cin >> lst_a[i];
rep(i, N) lst_a[i] -=... | [["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 22]] | 1 | 231 |
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(... | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(... | [["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 12, 13]] | 1 | 497 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (n); i++)
#define out(n) cout << n << endl;
int main() {
long long n, k, now = 1, range, loop;
bool flg = false;
cin >> n >> k;
int dp[n + 1][2], a[n + 1];
for (int i = 1; i < n + 1; i++) {
dp[i][0] = 0;
dp[i][1] = ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (n); i++)
#define out(n) cout << n << endl;
int main() {
long long n, k, now = 1, range, loop;
bool flg = false;
cin >> n >> k;
int dp[n + 1][2], a[n + 1];
for (int i = 1; i < n + 1; i++) {
dp[i][0] = 0;
dp[i][1] = ... | [["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22]] | 1 | 306 |
def main():
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=1
seen=[-1]*n
c=0
while seen[b-1]==-1:
seen[b-1]=c
b=a[b-1]
c+=1
start=seen[b-1]
end=c
k=start+(k-start)%(end-start)
b=1
for _ in range(k):
b=a[b-1]
print(b)
if __name__=='__main__':
main()
| def main():
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=1
seen=[-1]*n
c=0
while seen[b-1]==-1:
seen[b-1]=c
b=a[b-1]
c+=1
start=seen[b-1]
end=c
k=min(k,start+(k-start)%(end-start))
b=1
for _ in range(k):
b=a[b-1]
print(b)
if __name__=='__main__':
main()
| [["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]] | 5 | 141 |
N, K = map(int, input().split())
A_s = list(map(int, input().split()))
# それぞれの街に訪れた時のカウント
cache = [0]*N
# cacheの逆引き辞書
MAP = {}
# 町カーソル
i=0
# テレポーターのカウント
cnt=1
# 閉路のサイズ
rplng = 0
nolp = False
while(True):
if(cache[i]!=0):
rplng = cnt - cache[i]
break
if(cnt > K):
nolp = True
break... | N, K = map(int, input().split())
A_s = list(map(int, input().split()))
# それぞれの街に訪れた時のカウント
cache = [0]*N
# cacheの逆引き辞書
MAP = {}
# 町カーソル
i=0
# テレポーターのカウント
cnt=1
# 閉路のサイズ
rplng = 0
nolp = False
while(True):
if(cache[i]!=0):
rplng = cnt - cache[i]
break
if(cnt > K):
nolp = True
break... | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]] | 5 | 160 |
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
ans_list = [1]
history_list = [0 for _ in range(N)]
before_town = 1
loop_start_town = 10 ** 10
for i in range(N):
now_town = A_list[before_town - 1]
if history_list[now_town - 1] == 1:
break
ans_list.a... | # -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
ans_list = [1]
history_list = [0 for _ in range(N)]
before_town = 1
loop_start_town = 10 ** 10
for i in range(N):
now_town = A_list[before_town - 1]
if history_list[now_town - 1] == 1:
break
ans_list.a... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]] | 5 | 162 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() // string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
const ll MOD = 1000000007;
const ll INF = 1e18; // 1*10^18
const double PI ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() // string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
const ll MOD = 1000000007;
const ll INF = 1e18; // 1*10^18
const double PI ... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 16, 12, 16, 31, 69, 28, 22], ["-", 0, 16, 12, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 16, 12, 16, 31, 69, 341, 342, 0, 73]] | 1 | 847 |
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
rep(i, N) {
cin >> A.at(i);
A[i]--;
}
ll cur = 0;
ll step = 0;
vector<ll> V;
set<ll> S;
do {
if (... | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
rep(i, N) {
cin >> A.at(i);
A[i]--;
}
ll cur = 0;
ll step = 0;
vector<ll> V;
set<ll> S;
do {
if (... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 252 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */
int main(void) {
int n;
cin >> n;
ll k;
cin >> k;
map<int, int> tere;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
tere[i] = a;
}
ll len_roop = 0;
map<ll, ll> order;
ma... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */
int main(void) {
int n;
cin >> n;
ll k;
cin >> k;
map<int, int> tere;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
tere[i] = a;
}
ll len_roop = 0;
map<ll, ll> order;
ma... | [["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 263 |
/* */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
a = abs(a);
b = abs(b);
if (a < b)
swap(a, b);
while (b != 0) {
a %= b;
swap(a, b);
}
r... | /* */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
a = abs(a);
b = abs(b);
if (a < b)
swap(a, b);
while (b != 0) {
a %= b;
swap(a, b);
}
r... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 373 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(void) {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<int> visit(n + 1);
set<int> visited;
visit[0] = 0;
visited.insert(0);
... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(void) {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<int> visit(n + 1);
set<int> visited;
visit[0] = 0;
visited.insert(0);
... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 254 |
#include <iostream>
using namespace std;
typedef long long ll;
int main(int argc, char *argv[]) {
int N;
ll K;
int A[200005] = {0};
int C[200005] = {0};
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
int next = 1;
for (int i = 1; i <= N; i++) {
if (C[next] == 0) {
C[n... | #include <iostream>
using namespace std;
typedef long long ll;
int main(int argc, char *argv[]) {
int N;
ll K;
int A[200005] = {0};
int C[200005] = {0};
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
int next = 1;
for (ll i = 1; i <= K; i++) {
if (C[next] == 0) {
C[ne... | [["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 210 |
import sys
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)
flg = [False for _ in range(N + 1)]
town = []
i = 1
cnt = 0
for i in range(N):
town.append(i)
flg[i] = True
i = A[i]
if len(town) >= K:
print(town[K])
else:
s = i
... | import sys
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)
flg = [False for _ in range(N + 1)]
town = []
i = 1
cnt = 0
for _ in range(N):
town.append(i)
flg[i] = True
i = A[i]
if len(town) >= K:
print(town[K])
else:
s = i
... | [["-", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22]] | 5 | 157 |
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<int> num;
set<int> S;
num.push_back(0);
S.insert(0);
int front = a[0];
while (1) {
num.push... | #include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<int> num;
set<int> S;
num.push_back(0);
S.insert(0);
int front = a[0];
while (1) {
num.push... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 230 |
N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
import numpy as np
Nstock = np.zeros(N)
cpos = 1
Nstock[cpos - 1] = 1
stock = [cpos]
loop = []
idx = 0
for i in range(K):
cpos = A[cpos-1]
if Nstock[cpos - 1] == 1:
idx = stock.index(cpos)
loop = stock[... | N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
import numpy as np
Nstock = np.zeros(N)
cpos = 1
Nstock[cpos - 1] = 1
stock = [cpos]
loop = []
idx = 0
for i in range(K):
cpos = A[cpos-1]
if Nstock[cpos - 1] == 1:
idx = stock.index(cpos)
loop = stock[... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 172 |
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define ... | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define ... | [["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 365 |
N, K = map(int, input().split())
A = list(map(lambda x: x-1, map(int, input().split())))
T = [False]*N
initcount = 0
count = 0
cur = 0
for _ in range(N):
count += 1
T[cur] = True
cur = A[cur]
if T[cur]:
break
initcur = 0
for _ in range(count+1):
initcount += 1
initcur = A[initcur]
i... | N, K = map(int, input().split())
A = list(map(lambda x: x-1, map(int, input().split())))
T = [False]*N
initcount = 0
count = 0
cur = 0
for _ in range(N):
count += 1
T[cur] = True
cur = A[cur]
if T[cur]:
break
initcur = 0
for _ in range(count+1):
initcount += 1
initcur = A[initcur]
i... | [["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 189 |
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
ll N, K;
cin >> N >> K;
vector<ll> dist(N);
for (ll i = 0; i < N; i++) {
ll d;
cin >> d;
dist[i] = d - 1;
}
ll curr = 0;
vector<bool> v... | #include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
ll N, K;
cin >> N >> K;
vector<ll> dist(N);
for (ll i = 0; i < N; i++) {
ll d;
cin >> d;
dist[i] = d - 1;
}
ll curr = 0;
vector<bool> v... | [["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]] | 1 | 390 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
city = [-1 for i in range(0,N,1)]#0~N-1
count = 0
nex_city = 0
city[0]=0
while True:
city[nex_city] = count
nex_city = A[nex_city]-1
count+=1
if city[nex_city] >= 0:
break
X = nex_city
Y = count - city[nex_city]
nex_city = 0
if... | N,K = map(int,input().split())
A = list(map(int,input().split()))
city = [-1 for i in range(0,N,1)]#0~N-1
count = 0
nex_city = 0
city[0]=0
while True:
city[nex_city] = count
nex_city = A[nex_city]-1
count+=1
if city[nex_city] >= 0:
break
X = city[nex_city]
Y = count - city[nex_city]
nex_city ... | [["+", 0, 656, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73]] | 5 | 177 |
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]+p
flag=0
bef=1
town=[1]
town_set=set(town)
cnt=0
while flag==0 and cnt<k:
if not a[bef] in town_set:
town.append(a[bef])
town_set.add(a[bef])
bef=a[bef]
else:
flag=1
memo=a[bef]
cnt+=1
if cnt==k:
... | n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]+p
flag=0
bef=1
town=[1]
town_set=set(town)
cnt=0
while flag==0 and cnt<k:
if not a[bef] in town_set:
town.append(a[bef])
town_set.add(a[bef])
bef=a[bef]
else:
flag=1
memo=a[bef]
break
cnt+=1
i... | [["+", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]] | 5 | 176 |
#include <array>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
long int k;
std::array<int, 200000> next_town;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int next;
cin >> next;
next_town[i] = next - 1;
}
int current_index = 0;
std::ma... | #include <array>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
long int k;
std::array<int, 200000> next_town;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int next;
cin >> next;
next_town[i] = next - 1;
}
int current_index = 0;
std::ma... | [["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 12, 13]] | 1 | 186 |
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
for i in range(N):
A[i] -= 1
P = dict()
k = 0
former = True
i = 0
while i < K:
if k in P.keys() and former:
loop = i - P[k]
K = i + (K-i) % loop
former = False
else:
P[k] = i
k = A[k]
i += 1
el... | inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
for i in range(N):
A[i] -= 1
P = dict()
k = 0
former = True
i = 1
while i <= K:
if k in P.keys() and former:
loop = i - P[k]
K = i + (K-i) % loop
former = False
else:
P[k] = i
k = A[k]
i += 1
else:... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 36, 36, 0, 656, 0, 52, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 667, 19]] | 5 | 122 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1> void __f(const... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1> void __f(const... | [["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 435 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long N, K;
cin >> N >> K;
long A[N + 1];
for (long i = 1; i < N + 1; i++) {
cin >> A[i];
}
long pos = 1;
long tag[N + 1] = {0};
for (; K > 0; K--) {
pos = A[pos];
if (tag[pos] == 0) {
tag[pos] = K;
} else {
K = K %... | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, K;
cin >> N >> K;
long A[N + 1];
for (long i = 1; i < N + 1; i++) {
cin >> A[i];
}
long pos = 1;
long tag[N + 1] = {0};
while (K > 0) {
K--;
pos = A[pos];
// cout << pos << ' ' << tag[pos] << ' ' << K <<endl;
if (t... | [["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 88], ["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["-", 0, 30, 0, 14, 8, 9, 0, 7, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0... | 1 | 135 |
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
if K <= 200000:
i = 1
for _ in range(K):
i = A[i-1]
print(i)
exit()
visited = {1}
order = []
i = 1
for count in range(1, 200001):
i = A[i-1]
if i in visited:
break
else:
visited.add(i)
order.append(i)
idx = order.index... | N, K = map(int, input().split())
A = tuple(map(int, input().split()))
if K <= 200000:
i = 1
for _ in range(K):
i = A[i-1]
print(i)
exit()
visited = {1}
order = [1]
i = 1
for count in range(1, 200001):
i = A[i-1]
if i in visited:
break
else:
visited.add(i)
order.append(i)
idx = order.inde... | [["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 12, 657, 31, 23, 0, 657, 31, 657, 17, 72], ["+", 12, 657, 31, 23, 0, 657, 31, 657, 12, 612]] | 5 | 150 |
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
stack = deque([])
passed = set()
town = 0
while town not in passed:
passed.add(town)
stack.append(town)
town = A[town] - 1
if len(stack) > K:
print(stack[K])
import sys
sys.exit()
tail = 0
while... | from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
stack = deque([])
passed = set()
town = 0
while town not in passed:
passed.add(town)
stack.append(town)
town = A[town] - 1
if len(stack) > K:
print(stack[K] + 1)
import sys
sys.exit()
tail = 0
w... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 157 |
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
long long ans;
long long N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i] -= 1;
}
vector<int> B;
map... | #include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
long long ans;
long long N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i] -= 1;
}
vector<int> B;
map... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 288 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream> // istringstream
#include <string>
#include <vector>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long A[N + 1];
for (int i = 1; i < N + 1; ++i) {
cin >> A[i];
}
// 10^5回以内に必ずループする
long long memo[2... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream> // istringstream
#include <string>
#include <vector>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long A[N + 1];
for (int i = 1; i < N + 1; ++i) {
cin >> A[i];
}
// 10^5回以内に必ずループする
long long memo[2... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]] | 1 | 273 |
N,K=map(int,input().split())
A=list(map(int,input().split()))
visited=[0]*N#訪問フラグ
ima_pos=0#現在地
mirai_pos=0#移動先
count_first=0#一巡目のループ
first_DP=[]
while(visited[ima_pos]==0):
visited[ima_pos]=1#訪れたら更新
mirai_pos=A[ima_pos]-1
ima_pos=mirai_pos
first_DP.append(ima_pos)#何番目のインデックスに移動するか
count_first+=1#何回移動したか
s... | N,K=map(int,input().split())
A=list(map(int,input().split()))
visited=[0]*N#訪問フラグ
ima_pos=0#現在地
mirai_pos=0#移動先
count_first=0#一巡目のループ
first_DP=[]
while(visited[ima_pos]==0):
visited[ima_pos]=1#訪れたら更新
mirai_pos=A[ima_pos]-1
ima_pos=mirai_pos
first_DP.append(ima_pos)#何番目のインデックスに移動するか
count_first+=1#何回移動したか
s... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 205 |
import sys
a,b=map(int,input().split())
b=b+1
l=[0]*(a)
List=list(map(int,input().split()))
i=0
j=1
while l[i]==0 and j<b:
l[i]+=j
j+=1
i=List[i]-1
if j==b:
print(List[i])
sys.exit()
roop=j-l[i]
c=(b-j)%roop
for y in range(len(l)):
if l[y] ==c+l[i]:
print(y+1)
sys.exit() | import sys
a,b=map(int,input().split())
b=b+1
l=[0]*(a)
List=list(map(int,input().split()))
i=0
j=1
while l[i]==0 and j<b:
l[i]+=j
j+=1
i=List[i]-1
if j==b:
print(i+1)
sys.exit()
roop=j-l[i]
c=(b-j)%roop
for y in range(len(l)):
if l[y]==c+l[i]:
print(y+1)
sys.exit() | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 153 |
from collections import defaultdict
from sys import stdin
def main():
input = lambda: stdin.readline()[:-1]
N, K = map(int, input().split())
A = list(map(int, input().split()))
a, i = [0, 1], 0
for _ in [0] * N:
a.append(A[i])
i = A[i] - 1
if K <= N:
print(a[K])
... | from collections import defaultdict
from sys import stdin
def main():
input = lambda: stdin.readline()[:-1]
N, K = map(int, input().split())
A = list(map(int, input().split()))
a, i = [1], 0
for _ in [0] * N:
a.append(A[i])
i = A[i] - 1
if K <= N:
print(a[K])
... | [["-", 0, 1, 0, 662, 12, 432, 0, 634, 0, 612], ["-", 0, 1, 0, 662, 12, 432, 0, 634, 0, 21], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 31, 22], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 17, 33], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 12, 22]] | 5 | 202 |
// In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long a[MAXN];
long long n, k, ans = 0;
bool mark[MAXN];
long long tmp[MAXN], h[MAXN];
void dfs2(int v) {
k--;
if (k == 0) {
ans = v;
return;
}
dfs2(a[v]);
}
void dfs(int v, int p) {
if (mark[v])... | // In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long a[MAXN];
long long n, k, ans = 0;
bool mark[MAXN];
long long tmp[MAXN], h[MAXN];
void dfs2(int v) {
k--;
if (k == 0) {
ans = v;
return;
}
dfs2(a[v]);
}
void dfs(int v, int p) {
if (mark[v])... | [["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 288 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
vector<long long int> v(n + 1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
vector<int> vis(n + 1, 0);
int pi = 1;
int g = -1;
vector<long long int> s;
while (true) {
if (vis[pi] == 1) {
g =... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
vector<long long int> v(n + 1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
vector<int> vis(n + 1, 0);
int pi = 1;
int g = -1;
vector<long long int> s;
while (true) {
if (vis[pi] == 1) {
g =... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 235 |
#include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //... | #include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //... | [["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 341, 342, 0, 16, 31, 2, 3, 4, 0, 25], ["-", 31, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 382 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back
#... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back
#... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 44]] | 1 | 389 |
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (i = 0; i < (ll)n; ++i)
#define all(x) begin(x), end(x)
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
vector<ll> reached(N, 0);
vector<ll> loop;
ll i{0};
rep(i, N) cin >> A[i];
... | #include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (i = 0; i < (ll)n; ++i)
#define all(x) begin(x), end(x)
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
vector<ll> reached(N, 0);
vector<ll> loop;
ll i{0};
rep(i, N) cin >> A[i];
... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 246 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
template <class T> using v = std::vector<T>;
template <class T> using vv = v<v<T>>;
const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
// const int mod = 9982... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
template <class T> using v = std::vector<T>;
template <class T> using vv = v<v<T>>;
const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
// const int mod = 9982... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 893 |
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
ll A[200000];
ll order[200000];
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
order[i] = -1... |
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
ll A[200000];
ll order[200000];
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
order[i] = -1... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 228 |
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
class mint {
public:
ll x;
mint(ll x = 0) : x(x % mod) {}
mint &operator+=(const ... | #include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
class mint {
public:
ll x;
mint(ll x = 0) : x(x % mod) {}
mint &operator+=(const ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 588 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.