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 <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set \
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, ... | #include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set \
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, ... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 808 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
result=[1]
temp=1
for i in range(n):
temp=a[temp-1]
result.append(temp)
temp=result.index(result[len(result)-1])
c=len(result)-temp-1
if k<n:
print(result[k+1])
else:
print(result[temp+(k-temp)%c]) | n,k=map(int,input().split())
a=list(map(int,input().split()))
result=[1]
temp=1
for i in range(n):
temp=a[temp-1]
result.append(temp)
temp=result.index(result[len(result)-1])
c=len(result)-temp-1
if k<n:
print(result[k])
else:
print(result[temp+(k-temp)%c]) | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 120 |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
const int N = (int)2e5 + 7;
int n, a[N], p[N];
ll k;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <=... | #include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
const int N = (int)2e5 + 7;
int n, a[N], p[N];
ll k;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <=... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 282 |
#include <iostream>
using namespace std;
typedef long long ll;
ll n, m, a[200002], b[200002], s[200002], L, tmp, tmp2;
int main(void) {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
L = 1;
for (int i = 1; i <= n + 1; i++) {
b[i] = L;
if (s[L] != 0) {
tmp = i;
break;
... | #include <iostream>
using namespace std;
typedef long long ll;
ll n, m, a[200002], b[200002], s[200002], L, tmp, tmp2;
int main(void) {
cin >> n >> m;
m++;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
L = 1;
for (int i = 1; i <= n + 1; i++) {
b[i] = L;
if (s[L] != 0) {
tmp = i;
brea... | [["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 229 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
vector<int> doubling(vector<int> v, long long k) {
int n = v.size(), t = 1;
long long l = k;
while (l > 0) {
++t;
l /= 2;
}
vector<int> ans(n);
vector<vector<int>> tmp(t, vector<int>(n));
for (int i = 0; i... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
vector<int> doubling(vector<int> v, long long k) {
int n = v.size(), t = 1;
long long l = k;
while (l > 0) {
++t;
l /= 2;
}
vector<int> ans(n);
vector<vector<int>> tmp(t, vector<int>(n));
for (int i = 0; i... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 323 |
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
n, k = map(int, input().split())
f = list(map(lambda x : int(x) - 1, input().split()))
step = [-1] * n
step[0] = 0
now = 0
while step[f[now]] == -1:
... | import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
n, k = map(int, input().split())
f = list(map(lambda x : int(x) - 1, input().split()))
step = [-1] * n
step[0] = 0
now = 0
while step[f[now]] == -1:
... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 192 |
n, k = map(int, input().split())
num = list(map(int, input().split()))
t = [-1] * n
count = 0
s = 1
while t[s - 1] == -1:
if count == k:
break
t[s - 1] = count
count += 1
s = num[s - 1]
else:
z = (k - t[s - 1]) % (count - t[s - 1])
s = t.index(t[s - 1] + z + 1)
print(s)
| n, k = map(int, input().split())
num = list(map(int, input().split()))
t = [-1] * n
count = 0
s = 1
while t[s - 1] == -1:
if count == k:
break
t[s - 1] = count
count += 1
s = num[s - 1]
else:
z = (k - t[s - 1]) % (count - t[s - 1])
s = t.index(t[s - 1] + z) + 1
print(s)
| [["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 129 |
n, k = map(int, input().split())
q = list(map(int, input().split()))
v = [-1]*(n+1)
p = []
a = 1
c = 0
while 1:
if v[a] != -1:
l = c-v[a]
if k < c:
print(p[k])
else:
print(p[(k-v[a])%l+v[a]])
break
v[a] = c
c += 1
p.append(a)
a = q[a] | n, k = map(int, input().split())
q = list(map(int, input().split()))
v = [-1]*(n+1)
p = []
a = 1
c = 0
while 1:
if v[a] != -1:
l = c-v[a]
if k < c:
print(p[k])
else:
print(p[(k-v[a])%l+v[a]])
break
v[a] = c
c += 1
p.append(a)
a = q[a-1] | [["+", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 206, 206, 657, 12, 612]] | 5 | 132 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
at = A[at]-1
if visited[at]:
loop = i+1-path.index(at)
break
else:
visited[at]=True
path.append(at)
if K <= len(path):
pr... | N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
at = A[at]-1
if visited[at]:
loop = i+1-path.index(at)
break
else:
visited[at]=True
path.append(at)
if K < len(path):
pri... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 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]] | 5 | 154 |
//~raam
//~created : Jun 04, 2020 - 2.41.07 PM IST
using namespace std;
#include "bits/stdc++.h"
#define ll long long
void solve() {
ll n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
--a[i];
}
int vis[n] = {};
int cur = 0;
vector<int> cycle;
while (!vis[cur]) {
... | //~raam
//~created : Jun 04, 2020 - 2.41.07 PM IST
using namespace std;
#include "bits/stdc++.h"
#define ll long long
void solve() {
ll n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
--a[i];
}
int vis[n] = {};
int cur = 0;
vector<int> cycle;
while (!vis[cur]) {
... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 249 |
n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
v = []
vc = [0]*n
b = 0
c = 0
while True:
if vc[b]>0:
stop = v.index(b)
break
v.append(b)
vc[b] += 1
b = a[b]
c += 1
if k>c:
r = (k-stop)%(c-stop)
print(v[stop+r]+1)
else:
print(v[k]+1) | n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
v = []
vc = [0]*n
b = 0
c = 0
while True:
if vc[b]>0:
stop = v.index(b)
break
v.append(b)
vc[b] += 1
b = a[b]
c += 1
if k>stop:
r = (k-stop)%(c-stop)
print(v[stop+r]+1)
else:
print(v[k]+1)
| [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 134 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int N;
long long int K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
}
vector<int> seen(N, false);
int now = 0;
vector<int> path;
while (seen[now] != true) {
seen[now] = true;
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N;
long long int K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
}
vector<int> seen(N, false);
int now = 0;
vector<int> path;
while (seen[now] != true) {
seen[now] = true;
... | [["-", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]] | 1 | 213 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define REPD(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef ve... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define REPD(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef ve... | [["+", 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], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 593 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
n_buf = [0 for i in range(n)]
path_buf = []
now = 1
while True:
n_buf[now - 1] = 1
_next = a[now - 1]
path_buf.append(now)
if n_buf[_next - 1] == 1:
path_buf.append(_next)
break
now = _next
index = path_buf.inde... | n, k = map(int, input().split())
a = list(map(int, input().split()))
n_buf = [0 for i in range(n)]
path_buf = []
now = 1
while True:
n_buf[now - 1] = 1
_next = a[now - 1]
path_buf.append(now)
if n_buf[_next - 1] == 1:
path_buf.append(_next)
break
now = _next
index = path_buf.inde... | [["-", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 662, 12, 206, 206, 657, 12, 612]] | 5 | 174 |
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define vint vector<int>
#defi... | #include <algorithm>
#include <cfenv>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define vint vector<int>
#defi... | [["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 275 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define INF (int)1e9
#define pb push_back
#define fastIO \
ios::sync_with_st... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define INF (int)1e9
#define pb push_back
#define fastIO \
ios::sync_with_st... | [["-", 64, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 64, 1, 0, 16, 12, 69, 341, 342, 0, 22]] | 1 | 254 |
#include <bits/stdc++.h>
using namespace std;
long long n, arr[200005], counts[200005] = {0};
vector<long long> v;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
long long k, X;
cin >> k;
for (int i = 1; i <= n; i++)
cin >> arr[i];
long long idx = 1, num = 1, start;
while (1) {
... | #include <bits/stdc++.h>
using namespace std;
long long n, arr[200005], counts[200005] = {0};
vector<long long> v;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
long long k, X;
cin >> k;
for (int i = 1; i <= n; i++)
cin >> arr[i];
long long idx = 1, num = 1, start;
while (1) {
... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73]] | 1 | 221 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {
ll i, j;
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (i = 0; i < n; ++i) {
cin >> a.at(i);
}
vector<ll> kaisuu(n, -1);
kaisuu.at(0) = 0;
l... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {
ll i, j;
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (i = 0; i < n; ++i) {
cin >> a.at(i);
}
vector<ll> kaisuu(n, -1);
kaisuu.at(0) = 0;
l... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 281 |
n,k=list(map(int,input().split()))
a=[0]+ list(map(int,input().split()))
visited=[1]
for i in range(n):
next=a[visited[-1]]
visited.append(next)
loop_end=n
loop_start=n-1
while visited[loop_start]!=visited[loop_end]:
loop_start-=1
period=loop_end-loop_start
#print(visited)
#print("p:",period)
#print("k%peri... | n,k=list(map(int,input().split()))
a=[0]+ list(map(int,input().split()))
visited=[1]
for i in range(n):
next=a[visited[-1]]
visited.append(next)
loop_end=n
loop_start=n-1
while visited[loop_start]!=visited[loop_end]:
loop_start-=1
period=loop_end-loop_start
#print(visited)
#print("p:",period)
#print("(k-n)%... | [["+", 3, 4, 0, 206, 206, 657, 31, 657, 12, 22], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 135 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
rep(i, N) {
cin >> A[i];
A[i]--;
}
set<ll> se;
vector<ll>... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
int main() {
ll N, K;
cin >> N >> K;
vector<ll> A(N);
rep(i, N) {
cin >> A[i];
A[i]--;
}
set<ll> se;
vector<ll>... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 280 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
# mp = dict()
# for ix in range(N):
# mp[ix+1] = A[ix]
hist = []
exists = [0] * (N+1)
cur = 1
cnt = 0
# ここがおかしい?
# while True:
# cur = mp[cur]
# cnt += 1
# # K -= 1
# if exists[cur] != 0:
# break
# else:
# e... | N, K = map(int, input().split())
A = list(map(int, input().split()))
# mp = dict()
# for ix in range(N):
# mp[ix+1] = A[ix]
hist = []
exists = [0] * (N+1)
cur = 1
cnt = 0
# ここがおかしい?
# while True:
# cur = mp[cur]
# cnt += 1
# # K -= 1
# if exists[cur] != 0:
# break
# else:
# e... | [["-", 0, 662, 12, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 12, 22]] | 5 | 174 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (ll i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
set<ll> s;
vector<ll> order;
ll now = 0;
while (s.count(now) == 0) {
s.insert(now);
order.push_back(now);
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (ll i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
set<ll> s;
vector<ll> order;
ll now = 0;
while (s.count(now) == 0) {
s.insert(now);
order.push_back(now);
... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 189 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
ll k;
cin >> n >> k;
vector<int> vec(n);
for (int i = 0; i < n; ++i) {
cin >> vec[i];
vec[i]--;
}
vector<int> vec1;
set<int> s;
int co... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
ll k;
cin >> n >> k;
vector<int> vec(n);
for (int i = 0; i < n; ++i) {
cin >> vec[i];
vec[i]--;
}
vector<int> vec1;
set<int> s;
int co... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 263 |
N, K = map(int, input().split())
A_i = list(map(int, input().split()))
place = 1
road = [0 for i in range(N)]
cycle = 0
road[0] = 1
while K != 0:
place = A_i[place - 1]
K -= 1
if road[place - 1] == 1:
loop_place = place
break
road[place - 1] = 1
while K != 0:
loop_place = A_i[lo... | N, K = map(int, input().split())
A_i = list(map(int, input().split()))
place = 1
road = [0 for i in range(N)]
cycle = 0
road[0] = 1
while K != 0:
place = A_i[place - 1]
K -= 1
if road[place - 1] == 1:
loop_place = place
break
road[place - 1] = 1
while K != 0:
loop_place = A_i[loo... | [["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 79], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]] | 5 | 142 |
/*
* Author: $%U%$
* Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vvi = vector<vi>; // vector<vector<int>>
using vvll = vector<vll>;
using vs... | /*
* Author: $%U%$
* Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vvi = vector<vi>; // vector<vector<int>>
using vvll = vector<vll>;
using vs... | [["+", 64, 9, 0, 1, 0, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 1, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 12, 23, 0, 25]] | 1 | 1,043 |
#include <bits/stdc++.h>
#define FAST_IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define int long long int
using names... | #include <bits/stdc++.h>
#define FAST_IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define int long long int
using names... | [["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]] | 1 | 267 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
long long K;
cin >> N >> K;
int A[N];
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
}
int idx = 0;
int count = -1;
int fin[N];
for (int i = 0; i < N; i++)
fin[i] = -1;
while (fin[idx] == -1) {
fin[idx] = coun... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
long long K;
cin >> N >> K;
int A[N];
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
}
int idx = 0;
int count = 0;
int fin[N];
for (int i = 0; i < N; i++)
fin[i] = -1;
while (fin[idx] == -1) {
fin[idx] = count... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 199 |
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
vector<int> town(N);
for (int i = 0; i < N; i++) {
cin >> town.at(i);
town.at(i) = town.at(i) - 1;
}
int now = 0;
vector<int> count(N, 0);
long long roop_town, rest;
bool flag =... | #include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
vector<int> town(N);
for (int i = 0; i < N; i++) {
cin >> town.at(i);
town.at(i) = town.at(i) - 1;
}
int now = 0;
vector<int> count(N, 0);
long long roop_town, rest;
bool flag =... | [["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22]] | 1 | 219 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long k;
scanf("%d %d", &n, &k);
vector<int> adj(n);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
adj[i] = x - 1;
}
long long last_time_visited[n];
memset(last_time_visited, -1, sizeof(last_time_visited));
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long k;
scanf("%d %lld", &n, &k);
vector<int> adj(n);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
adj[i] = x - 1;
}
long long last_time_visited[n];
memset(last_time_visited, -1, sizeof(last_time_visited));
... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 188 |
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int A;
cin >> A;
a[i] = --A;
}
int ptr = ... | #include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int A;
cin >> A;
a[i] = --A;
}
int ptr = ... | [["+", 12, 16, 12, 23, 0, 16, 31, 16, 12, 13], ["+", 12, 16, 12, 16, 12, 23, 0, 16, 17, 33]] | 1 | 165 |
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
REP(i, n) cin >> a[i];
vector<int> ans;
vector<int> road(n + 1, -1);
int tail = 0;
int roop = 1;
int i = 1;
... | #include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
REP(i, n) cin >> a[i];
vector<int> ans;
vector<int> road(n + 1, -1);
int tail = 0;
int roop = 1;
int i = 1;
... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 199 |
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset> // bitset
#include <deque> // deque
#include <iomanip> // setprecsion
#include <iostream> // cout, endl, cin
#include <map> // map
#include <queue> // queue, priori... | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset> // bitset
#include <deque> // deque
#include <iomanip> // setprecsion
#include <iostream> // cout, endl, cin
#include <map> // map
#include <queue> // queue, priori... | [["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]] | 1 | 590 |
N,K=map(int,input().split())
array=map(int,input().split())
A=list(array)
A.insert(0,0)
visit=0
root=[]
visited=1
once=0
while True:
if visit & (0b1<<visited):
break
root.append(visited)
visit|=0b1<<visited
once+=1
visited=A[visited]
roop=root[root.index(visited):]
if K<=once:
print(... | N,K=map(int,input().split())
array=map(int,input().split())
A=list(array)
A.insert(0,0)
visit=0
root=[]
visited=1
once=0
while True:
if visit & (0b1<<visited):
break
root.append(visited)
visit|=0b1<<visited
once+=1
visited=A[visited]
roop=root[root.index(visited):]
if K<once:
print(r... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 133 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main() {
int n;
ull k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
a.at(i)--;
}
vector<int> flag(n);
vector<... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//うまくいかなかった(原因は24行目)
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
a.at(i)--;
}
vector<int... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 261 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main() {
int n;
ull k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
a.at(i)--;
}
vector<int> flag(n);
vector<... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main() {
int n;
ull k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
a.at(i)--;
}
vector<int> flag(n);
vector<... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 261 |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
const long long mod = 1e9 + 7;
//////////////////////////////////
int main() {
long long n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
if (a[0] == 0) {
cout << 1 << ... | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
const long long mod = 1e9 + 7;
//////////////////////////////////
int main() {
long long n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
if (a[0] == 0) {
cout << 1 << ... | [["-", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 209 |
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;
int ... | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;
int ... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 276 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
l = [-1]*(n + 1)
l[1] = 1
order = 1
now = 0
while k > 0:
k -= 1
now = a[now]
order += 1
if l[now] == -1:
l[now] = order
else:
loop = order - l[now] + 1
k %= loop
... | n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
l = [-1]*(n + 1)
l[0] = 0
order = 0
now = 0
while k > 0:
k -= 1
now = a[now]
order += 1
if l[now] == -1:
l[now] = order
else:
loop = order - l[now]
k %= loop
brea... | [["-", 0, 656, 0, 1, 0, 662, 31, 206, 206, 612], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 206, 612], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 139 |
#include <algorithm>
#include <functional>
#include <math.h>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
long long k;
int x;
scanf("%d %lld", &n, &k);
vector<int> next(n);
for (int i = 0; i < n; ++i) {
scanf("%... | #include <algorithm>
#include <functional>
#include <math.h>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
long long k;
int x;
scanf("%d %lld", &n, &k);
vector<int> next(n);
for (int i = 0; i < n; ++i) {
scanf("%... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13]] | 1 | 279 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
int INF = 100010100;
vector<int> AList(N + 1);
vector<int> firstStep(N + 1, INF);
vector<int> history;
rep(i, N) {
int s;
cin >> s;
AList[i + 1] = s;
}
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
int INF = 100010100;
vector<int> AList(N + 1);
vector<int> firstStep(N + 1, INF);
vector<int> history;
rep(i, N) {
int s;
cin >> s;
AList[i + 1] = s;
}
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 214 |
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int64_t n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; i++)
std::cin >> a[i];
std::vector<bool> visited(n, false);
int v = 1;
while (!visited[v - 1]) {
visited[v - 1] = true;
v = a[v - 1];
}
... | #include <algorithm>
#include <iostream>
#include <vector>
int main() {
int64_t n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; i++)
std::cin >> a[i];
std::vector<bool> visited(n, false);
int v = 1;
while (!visited[v - 1]) {
visited[v - 1] = true;
v = a[v - 1];
}
... | [["+", 0, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 0, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 0, 7, 15, 16, 12, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25]] | 1 | 240 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long N, K;
cin >> N >> K;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a[i];
a[i]--;
}
long now = 0;
vector<int> v(N);
while (K > 0) {
now = a[now];
K--;
// cout<<now+1<<endl;
if (v[now] == 1) {
v[now]+... | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, K;
cin >> N >> K;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a[i];
a[i]--;
}
long now = 0;
vector<int> v(N);
while (K > 0) {
now = a[now];
K--;
// cout<<now+1<<endl;
if (v[now] == 1) {
v[now]+... | [["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]] | 1 | 207 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000000)
stp = -1
def main():
n, k = map(int, readline().split())
a = [int(i)-1 for i in readline().split()]
order = []
ex = set()
def dfs(node):
glo... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000000)
stp = -1
def main():
n, k = map(int, readline().split())
a = [int(i)-1 for i in readline().split()]
order = []
ex = set()
def dfs(node):
glo... | [["-", 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]] | 5 | 200 |
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) \
(void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
int main() {
ios::sync_with_stdio(false);
... | #include <bits/stdc++.h>
using namespace std;
#define DBG(x) \
(void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
int main() {
ios::sync_with_stdio(false);
... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 331 |
N, K = map(int, input().split())
A = list(map(int,input().split()))
moved = {}
now_city = 1
next_city = A[0]
i=0
while i < N:
moved[now_city] = i
if next_city in moved:
break
now_city = next_city
next_city = A[now_city-1]
i += 1
# i 回目の試行で、now_city から next_city に移ろうとしている
mod = i - moved... | N, K = map(int, input().split())
A = list(map(int,input().split()))
moved = {}
now_city = 1
next_city = A[0]
i=0
while i < N:
moved[now_city] = i
if next_city in moved:
break
now_city = next_city
next_city = A[now_city-1]
i += 1
# i 回目の試行で、now_city から next_city に移ろうとしている
mod = i - moved... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 164 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repit(it, li) for (auto it = li.begin(); it != li.end(); it++)
#define ll long long int
int main() {
int n;
ll k;
cin >> n >> k;
int a[200000];
rep(i, n) cin >> a[i], a[i]--;
map<int, int> reached;
int c... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repit(it, li) for (auto it = li.begin(); it != li.end(); it++)
#define ll long long int
int main() {
int n;
ll k;
cin >> n >> k;
int a[200000];
rep(i, n) cin >> a[i], a[i]--;
map<int, int> reached;
int c... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 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 | 202 |
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 20;
int n, a[N], vis[N], cycle, dp[N];
long long k;
void go(int node, int steps = 1) {
vis[node] = steps;
dp[node] = steps;
int child = a[node];
if (vis[child] == 0)
go(child, steps + 1);
else
cycle = child;
}
int main() {
scanf("... | #include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 20;
int n, a[N], vis[N], cycle, dp[N];
long long k;
void go(int node, int steps = 1) {
vis[node] = steps;
dp[steps] = node;
int child = a[node];
if (vis[child] == 0)
go(child, steps + 1);
else
cycle = child;
}
int main() {
scanf("... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22]] | 1 | 236 |
def resolve():
n, k = map(int, input().split())
g = list(map(int, input().split()))
disc = [-1]*(n+1)
s = []
v = 1
c = 0
while disc[v] == -1:
disc[v] = len(s)
s.append(v)
v = g[v-1]
c = len(s) - disc[v]
l = len(s)
if l > k:
print(s[k])
else... | def resolve():
n, k = map(int, input().split())
g = list(map(int, input().split()))
disc = [-1]*(n+1)
s = []
v = 1
c = 0
while disc[v] == -1:
disc[v] = len(s)
s.append(v)
v = g[v-1]
c = len(s) - disc[v]
l = len(s)
if l > k:
print(s[k])
else... | [["+", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 206, 206, 657, 12, 612]] | 5 | 156 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
visited = []
search = set()
now = 1#最初の街にいる
next_town = A[now-1]
count = 1
while(count<=N):
if next_town in search:#もし次の街が訪れたことがある場合
break#ループするので抜け出す
visited.append(now)#今いる街は訪れたこととなるので記録する
search.add(now)
next_town = A[now-1]#次に... | N,K = map(int,input().split())
A = list(map(int,input().split()))
visited = []
search = set()
now = 1#最初の街にいる
next_town = A[now-1]
count = 1
while(count<=N):
if next_town in search:#もし次の街が訪れたことがある場合
break#ループするので抜け出す
visited.append(now)#今いる街は訪れたこととなるので記録する
search.add(now)
next_town = A[now-1]#次に... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 166 |
N,K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A_done = [0]*N
A_route = []
point = 1
end_point = 0
while A_done[point-1]==0:
A_done[point-1] = 1
A_route.append(point)
point = A[point-1]
if A_done[point-1]==1:
end_point = point
cal = K%len(A_route)
roop = A_route.index(end_po... | N,K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A_done = [0]*N
A_route = []
point = 1
end_point = 0
while A_done[point-1]==0:
A_done[point-1] = 1
A_route.append(point)
point = A[point-1]
if A_done[point-1]==1:
end_point = point
cal = K%len(A_route)
roop = A_route.index(end_po... | [["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]] | 5 | 181 |
#include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b);... | #include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b);... | [["+", 75, 76, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 351 |
#include <bits/stdc++.h>
#define M 200006
#define ll long long int
using namespace std;
int c[M][66];
int n, goal = 1, t;
ll m;
void bz() {
int len = log(m) / log(2) + 1;
for (int i = 1; i <= len; ++i)
for (int j = 1; j <= n; ++j) {
c[j][i] = c[c[j][i - 1]][i - 1];
}
}
int main() {
cin >> n >> m;
... | #include <bits/stdc++.h>
#define M 200006
#define ll long long int
using namespace std;
int c[M][66];
int n, goal = 1, t;
ll m;
void bz() {
int len = log(m) / log(2) + 1;
for (int i = 1; i <= len; ++i)
for (int j = 1; j <= n; ++j) {
c[j][i] = c[c[j][i - 1]][i - 1];
}
}
int main() {
cin >> n >> m;
... | [["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 23, 0, 16, 17, 152], ["-", 15, 339, 51, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25]] | 1 | 191 |
import numpy as np
def check_num_of_remaining_teleport(num_of_teleport, i):
if num_of_teleport == 0:
print(i)
exit()
num_of_town, num_of_teleport = map(int, input().split())
town = np.array(list(map(int, input().split())))
# 香り高い町の探索
i = 1
# テレポートの移動ルールに合わせて1始まりにする
fragranttown_index = 1
fragrant... | import numpy as np
def check_num_of_remaining_teleport(num_of_teleport, i):
if num_of_teleport == 0:
print(i)
exit()
num_of_town, num_of_teleport = map(int, input().split())
town = np.array(list(map(int, input().split())))
# 香り高い町の探索
i = 1
# テレポートの移動ルールに合わせて1始まりにする
fragranttown_index = 1
fragrant... | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 217 |
n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
lst=[0]
now=0
memo=0
town=[0]*n
town[0]=1
b=0
for i in range(k):
now=a[now]
if town[now]==1:
memo=now
b=1
break
lst.append(now)
town[now]=1
if b==1:
i=lst.index(memo)
l=len(lst)
if memo!=0:
lst=lst[i:]
l-=len(lst)
print(lst[(... | n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
lst=[0]
now=0
memo=0
town=[0]*n
town[0]=1
b=0
for i in range(k):
now=a[now]
if town[now]==1:
memo=now
b=1
break
lst.append(now)
town[now]=1
if b==1:
i=lst.index(memo)
l=len(lst)
if memo!=0:
lst=lst[i:]
l-=len(lst)
print(lst[(... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 183 |
num_town, num_move = map(int, input().split())
teleports = list(map(lambda x: int(x) - 1, input().split()))
current = 0
memo = {}
for i in range(num_move):
if memo.get(current) == 2:
break
if not memo.get(current):
memo[current] = 1
else:
memo[current] += 1
destination = telepor... | num_town, num_move = map(int, input().split())
teleports = list(map(lambda x: int(x) - 1, input().split()))
current = 0
memo = {}
for i in range(num_move):
if memo.get(current) == 2:
break
if not memo.get(current):
memo[current] = 1
else:
memo[current] += 1
destination = telepor... | [["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]] | 5 | 195 |
N, K = map(int,input().split())
Map = list(map(int,input().split()))
Visited = [-1]*N
now = 1
Order = [0]*N
loopcount = 1
Order[0] = 1
Visited[0] = 1
for i in range(1,N):
nt = Map[now-1]
Order[i] = nt
loopcount += 1
if Visited[nt-1] == -1:
Visited[nt-1] = loopcount
else:
break
... | N, K = map(int,input().split())
Map = list(map(int,input().split()))
Visited = [-1]*N
now = 1
Order = [0]*N
loopcount = 1
Order[0] = 1
Visited[0] = 1
for i in range(1,N):
nt = Map[now-1]
Order[i] = nt
loopcount += 1
if Visited[nt-1] == -1:
Visited[nt-1] = loopcount
else:
break
... | [["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22]] | 5 | 159 |
#include <algorithm>
#include <cmath>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp... | #include <algorithm>
#include <cmath>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 328 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <signal.h>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#defin... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <signal.h>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#defin... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 12, 13]] | 1 | 730 |
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int, int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < int__(n); i++)
#define sz(a) int__(a.size()... | #include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int, int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < int__(n); i++)
#define sz(a) int__(a.size()... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 574 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define N_MAX (12)
#define M_MAX (12)
int main() {
int N, K;
cin >> N >> K;
vector<int> A(N);
vector<int> index(N, -1);
rep(i, N) {
int tmp;
cin >> tmp;
tmp--;
A.at(i) =... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define N_MAX (12)
#define M_MAX (12)
int main() {
int N;
ll K;
cin >> N >> K;
vector<int> A(N);
vector<int> index(N, -1);
rep(i, N) {
int tmp;
cin >> tmp;
tmp--;
A.at... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 256 |
/*
このコード、と~おれ!
Be accepted!
∧_∧
(。・ω・。)つ━☆・*。
⊂ ノ ・゜+.
しーJ °。+ *´¨)
.· ´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·'* ☆
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <ioma... | /*
このコード、と~おれ!
Be accepted!
∧_∧
(。・ω・。)つ━☆・*。
⊂ ノ ・゜+.
しーJ °。+ *´¨)
.· ´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·'* ☆
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <ioma... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 644 |
// In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long long k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
set<int> seen;
int now = 0;
while (k) {... | // In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long long k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
set<int> seen;
int now = 0;
while (k) {... | [["+", 64, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 12, 13]] | 1 | 210 |
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> d(n... | #include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> d(n... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 201 |
n,k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
visited = [False]*n
p = 0
visited[0] = True
cnt = 0
while True:
if visited[a[p]]:
rp = a[p]
cnt += 1
break
else:
visited[a[p]] = True
p = a[p]
cnt += 1
if cnt == k:
print(a[p]+1... | n,k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
visited = [False]*n
p = 0
visited[0] = True
cnt = 0
while True:
if visited[a[p]]:
rp = a[p]
cnt += 1
break
else:
visited[a[p]] = True
p = a[p]
cnt += 1
if cnt == k:
print(p+1)
... | [["-", 0, 652, 3, 4, 0, 657, 31, 206, 51, 22], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 0, 73]] | 5 | 203 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
rd = [-1 for _ in range(N)]
rd[0] = 1
def nomal_loop():
now_town = 1
for _ in range(K):
now_town = A[now_town]
print(now_town)
return 0
def else_loop():
next_town = A[0]
count = 1
K_count = K
while(1):
c... | N,K = map(int,input().split())
A = list(map(int,input().split()))
rd = [-1 for _ in range(N)]
rd[0] = 1
def nomal_loop():
now_town = 1
for _ in range(K):
now_town = A[now_town-1]
print(now_town)
return 0
def else_loop():
next_town = A[0]
count = 1
K_count = K
while(1):
... | [["+", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 206, 206, 657, 12, 612]] | 5 | 192 |
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n;
long long k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> order(n + 1, -1);
vector<int> recode;
int v = 1, freq = 1, nonloop = 0;
while (order[v] == -1) {
ord... | #include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n;
long long k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> order(n + 1, -1);
vector<int> recode;
int v = 1, freq = 1, nonloop = 0;
while (order[v] == -1) {
ord... | [["-", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]] | 1 | 185 |
# D - Teleporter
def main():
N, K, *A = map(int, open(0).read().split())
A = [0] + A
last_visit = [-1] * (N + 1)
last_visit[1] = 0
cur_pos, i = 1, 1
while True:
nxt_pos = A[cur_pos]
if i == K:
print(cur_pos)
break
elif (j := last_visit[nx... | # D - Teleporter
def main():
N, K, *A = map(int, open(0).read().split())
A = [0] + A
last_visit = [-1] * (N + 1)
last_visit[1] = 0
cur_pos, i = 1, 1
while True:
nxt_pos = A[cur_pos]
if i == K:
print(nxt_pos)
break
elif (j := last_visit[nxt_pos]) ... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 139 |
#include <algorithm>
#include <cmath> //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <deque>
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip> //cout<<setw(数字) で空白による桁揃え
#include <iostream> //cout<<right で右揃え
#include <map>
#include <queue>
#include <string>
#include <vector>
u... | #include <algorithm>
#include <cmath> //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <deque>
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip> //cout<<setw(数字) で空白による桁揃え
#include <iostream> //cout<<right で右揃え
#include <map>
#include <queue>
#include <string>
#include <vector>
u... | [["+", 15, 339, 51, 16, 12, 16, 31, 74, 0, 24], ["+", 51, 16, 12, 16, 31, 74, 39, 77, 39, 78], ["+", 15, 339, 51, 16, 12, 16, 31, 74, 0, 25], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 340 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a[0]
hist = [1]
passed = [0] * n
flag = 0
for i, _ in enumerate(range(k), start=1):
if passed[idx-1] == 1:
hist.append(idx)
passed[idx-1] = 1
flag = 1
break
hist.append(idx)
passed[idx-1] = 1
idx ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a[0]
hist = [1]
passed = [0] * n
flag = 0
for i, _ in enumerate(range(k), start=1):
if passed[idx-1] == 1:
hist.append(idx)
passed[idx-1] = 1
flag = 1
break
hist.append(idx)
passed[idx-1] = 1
idx ... | [["+", 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]] | 5 | 166 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k;
vector<int> a;
map<int, int> m;
vector<int> order;
int now = 0;
int cyclestart = -1;
void dfs(int node) {
auto it = m.find(node);
if (it != m.end()) {
cyclestart = node;
return;
}
m[node] = now++;
order.push_back(node);
d... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k;
vector<int> a;
map<int, int> m;
vector<int> order;
int now = 0;
int cyclestart = -1;
void dfs(int node) {
auto it = m.find(node);
if (it != m.end()) {
cyclestart = node;
return;
}
m[node] = now++;
order.push_back(node);
d... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 255 |
n,k,*a=map(int,open(0).read().split())
d=[2*k]*n
s=0
while k:s=a[s]-1;d[s]=k=~-k%(d[s]-k)
print(s+1) | n,k,*a=map(int,open(0).read().split())
d=[2*k]*n
s=0
while k:s=a[s]-1;d[s]=k=~-k%(d[s]+1-k)
print(s+1) | [["+", 12, 657, 12, 23, 0, 657, 31, 657, 17, 72], ["+", 12, 657, 12, 23, 0, 657, 31, 657, 12, 612]] | 5 | 73 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
vector<int> b(n + 1);
int j = 1;
int i;
for (i = 1; i < n + 3; i++) {... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n;
ll k;
cin >> n >> k;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
vector<int> b(n + 1);
int j = 1;
int i;
for (i = 1; i < n + 3; i++) {... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13]] | 1 | 242 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
NN = [-1] * N
NN[0] = 0
i = 0
num = 0
while True:
num += 1
i = A[i] - 1
if NN[i] != -1:
n1 = NN[i]
break
NN[i] = num
n_ = num - n1
if K > N:
K -= n1
t = NN.index(n1 + K % n_) + 1
print(t)
else:
t = ... | N, K = map(int, input().split())
A = list(map(int, input().split()))
NN = [-1] * N
NN[0] = 0
i = 0
num = 0
while True:
num += 1
i = A[i] - 1
if NN[i] != -1:
n1 = NN[i]
break
NN[i] = num
n_ = num - n1
if K > n1:
K -= n1
t = NN.index(n1 + K % n_) + 1
print(t)
else:
t =... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 75, 76, 8, 196, 0, 1, 0, 657, 17, 72], ["-", 75, 76, 8, 196, 0, 1, 0, 657, 12, 612]] | 5 | 136 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
d=[-1]*(n+1)
v=1
while(d[v]==-1):
d[v]=len(s)
s.append(v)
v=a[v-1]
c=len(s)-d[v]
l=d[v]
if(k<l):print(s[k])
else:
k-=l
k%=c
print(k+l) | n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
d=[-1]*(n+1)
v=1
while(d[v]==-1):
d[v]=len(s)
s.append(v)
v=a[v-1]
c=len(s)-d[v]
l=d[v]
if(k<l):print(s[k])
else:
k-=l
k%=c
print(s[k+l]) | [["+", 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]] | 5 | 131 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int N = s.nextInt();
long K = Long.parseLong(s.next());
int[] A = new int[N + 1];
for (int i = 1; i < N + 1; i++) {
A[i] = s.nextInt();
}
List<Integer> list = new Arr... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int N = s.nextInt();
long K = Long.parseLong(s.next());
int[] A = new int[N + 1];
for (int i = 1; i < N + 1; i++) {
A[i] = s.nextInt();
}
List<Integer> list = new Arr... | [["-", 8, 196, 0, 57, 15, 15, 0, 492, 141, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 492, 141, 22]] | 3 | 296 |
def function():
_N,K = map(int, input().split())
teleportes = list(map(int, input().split()))
# ループを見つける
i,count = 0,0
visited = [-1] * len(teleportes) # 訪れた街にチェック
while True :
if visited[i] == -1: # 最初に訪れた
visited[i] = count # 何番目に訪れたかを記録
i = teleportes[i] - 1
... | def function():
_N,K = map(int, input().split())
teleportes = list(map(int, input().split()))
# ループを見つける
i,count = 0,0
visited = [-1] * len(teleportes) # 訪れた街にチェック
while True :
if visited[i] == -1: # 最初に訪れた
visited[i] = count # 何番目に訪れたかを記録
i = teleportes[i] - 1
... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]] | 5 | 158 |
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
def main():
N,K=map(int,input().split())
... | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
def main():
N,K=map(int,input().split())
... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 656, 0, 14, 8, 196, 0, 57, 0, 121], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 14, 8, 196, 0, 57, 0, 102]] | 5 | 274 |
n,k = map(int,input().split())
a = list(map(int,input().split()))
now = 1
ss = set([1])
sw = 0
x = 0
for i in range(k):
now = a[now-1]
ss.add(now)
if len(ss) != i+2:
b = now
x = i+1
sw = 1
break
y = 0
now2 = -1
for j in range(x-1):
if now2 == b:
y = j+1
now2 ... | n,k = map(int,input().split())
a = list(map(int,input().split()))
now = 1
ss = set([1])
sw = 0
x = 0
for i in range(k):
now = a[now-1]
ss.add(now)
if len(ss) != i+2:
b = now
x = i+1
sw = 1
break
y = 0
now2 = 1
for j in range(x-1):
if now2 == b:
y = j
break... | [["-", 0, 656, 0, 1, 0, 662, 12, 664, 17, 33], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]] | 5 | 167 |
if __name__ == "__main__":
n, k = map(int, input().split())
a = list(map(int, input().split()))
history = []
visited = [False] * n
for i in range(n):
a[i] -= 1
now = 0
while k > 0 and not visited[now]:
visited[now] = True
history.append(now)
now = a[no... | if __name__ == "__main__":
n, k = map(int, input().split())
a = list(map(int, input().split()))
history = []
visited = [False] * n
for i in range(n):
a[i] -= 1
now = 0
while k > 0 and not visited[now]:
visited[now] = True
history.append(now)
now = a[no... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 148 |
N, K = map(int, input().split())
X = list(map(int, input().split()))
town = []
dic = {}
i = 0
j = 0
while i not in dic and j < K:
dic[i] = j
town.append(i)
i = X[i] - 1
j += 1
if j == K:
print(town[K] + 1)
else:
num = dic[i]
loop = j - num
print(town[((K - num) % loop) + num] + 1)
| N, K = map(int, input().split())
X = list(map(int, input().split()))
town = []
dic = {}
i = 0
j = 0
while i not in dic and j < K:
dic[i] = j
town.append(i)
i = X[i] - 1
j += 1
if j == K:
print(i + 1)
else:
num = dic[i]
loop = j - num
print(town[((K - num) % loop) + num] + 1)
| [["-", 0, 652, 3, 4, 0, 657, 31, 206, 51, 22], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 206, 22], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 0, 73], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]] | 5 | 126 |
#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
vector<int> a(maxn), vis(maxn, -1);
int i, j, n, k, cur, num, l;
int main() {
cin >> n >> k;
for (i = 0; i < n; i++)
cin >> a[i], a[i] -= 1;
while (vis[cur] == -1 && num < k) {
vis[cur] = num;
cur = a[cur];
num++;
}
k -= vis[cur... | #include <bits/stdc++.h>
using namespace std;
#define maxn 200005
vector<int> a(maxn), vis(maxn, -1);
long long i, j, n, k, cur, num, l;
int main() {
cin >> n >> k;
for (i = 0; i < n; i++)
cin >> a[i], a[i] -= 1;
while (vis[cur] == -1 && num < k) {
vis[cur] = num;
cur = a[cur];
num++;
}
k -= v... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]] | 1 | 158 |
#include <algorithm>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
// #define DEBUG
const int NUM = 2 * 10e5 + 1;
// 存储
long long list[NUM];
// 标志访问
bool visit[NUM];
// 回路栈
vector<long long> vec;
int main() {
#ifdef DEBUG
freopen("debug/test.txt", "r", stdin);
freopen("debug/resu... | #include <algorithm>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
// #define DEBUG
const int NUM = 2 * 10e5 + 1;
// 存储
long long list[NUM];
// 标志访问
bool visit[NUM];
// 回路栈
vector<long long> vec;
int main() {
#ifdef DEBUG
freopen("debug/test.txt", "r", stdin);
freopen("debug/resu... | [["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 331 |
/*
AUTHOR: Aman Raj
LANG: C++
*/
using namespace std;
typedef long long ll;
#include <bits/stdc++.h>
// setbase - cout << setbase (16); cout << 100 << endl; Prints 64
// setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints
// xxx77 setprecision - cout << setprecision (14) << f << endl; Prints x.... | /*
AUTHOR: Aman Raj
LANG: C++
*/
using namespace std;
typedef long long ll;
#include <bits/stdc++.h>
// setbase - cout << setbase (16); cout << 100 << endl; Prints 64
// setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints
// xxx77 setprecision - cout << setprecision (14) << f << endl; Prints x.... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 322 |
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)
using ll = long long;
using namespace std;
int main() {
int n;
ll k;
cin >> n >> k;
struct Node {
... | #include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)
using ll = long long;
using namespace std;
int main() {
int n;
ll k;
cin >> n >> k;
struct Node {
... | [["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 275 |
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int n;
long long k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; i++)
std::cin >> a[i];
std::vector<int> point(n + 1, -1);
std::vector<int> log;
int v = 1;
while (point[v] == -1) {
point[v] = log.s... | #include <algorithm>
#include <iostream>
#include <vector>
int main() {
int n;
long long k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; i++)
std::cin >> a[i];
std::vector<int> point(n + 1, -1);
std::vector<int> log;
int v = 1;
while (point[v] == -1) {
point[v] = log.s... | [["-", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["-", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+",... | 1 | 194 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> a(n);
for (long long i = 0; i < n; i++) {
cin >> a.at(i);
}
vector<int> ord(n + 1, -1);
vector<int> s;
int v = 1;
while (ord.at(v) == -1) {
ord.at(v) = s.size();
s.push_back(v);
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> a(n);
for (long long i = 0; i < n; i++) {
cin >> a.at(i);
}
vector<int> ord(n + 1, -1);
vector<int> s;
int v = 1;
while (ord.at(v) == -1) {
ord.at(v) = s.size();
s.push_back(v);
... | [["-", 0, 16, 31, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 16, 31, 16, 12, 2, 63, 118, 28, 22], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22]] | 1 | 200 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
R = [False] * (N + 1)
D = []
p = 1
while True:
if R[p]:
break
D.append(p)
R[p] = True
p = A[p - 1]
m = D.index(p)
... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
R = [False] * (N + 1)
D = []
p = 1
while True:
if R[p]:
break
D.append(p)
R[p] = True
p = A[p - 1]
m = D.index(p)
... | [["+", 0, 206, 206, 657, 12, 657, 31, 23, 0, 24], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 0, 73], ["+", 0, 206, 206, 657, 12, 657, 31, 23, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]] | 5 | 141 |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func readInt() int {
sc.Scan()
i, err := strconv.Atoi(sc.Text())
if err != nil {
panic(err)
}
return i
}
func readString() string {
sc.Scan()
return sc.Text()
}
func readInt64() int64 {
sc.Scan()
i, err := strco... | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func readInt() int {
sc.Scan()
i, err := strconv.Atoi(sc.Text())
if err != nil {
panic(err)
}
return i
}
func readString() string {
sc.Scan()
return sc.Text()
}
func readInt64() int64 {
sc.Scan()
i, err := strco... | [["-", 0, 57, 15, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 57, 15, 16, 12, 2, 3, 4, 0, 22]] | 7 | 498 |
n, k = map(int, input().split())
A = list(map(int, input().split()))
order = [-1] * (n+1)
v = [0] * (n+1)
v[0] = 1
order[v[0]] = 0
# iは順番
for i in range(1, n+1):
v[i] = A[v[i-1] - 1]
if order[v[i]] != -1:
old_i = order[v[i]]
c = i - old_i
break
order[v[i]] = i
if k < old_i:
print... | n, k = map(int, input().split())
A = list(map(int, input().split()))
order = [-1] * (n+1)
v = [0] * (n+1)
v[0] = 1
order[v[0]] = 0
# iは順番
for i in range(1, n+1):
v[i] = A[v[i-1] - 1]
if order[v[i]] != -1:
old_i = order[v[i]]
c = i - old_i
break
order[v[i]] = i
if k < old_i:
print... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 167 |
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int a[N], n, vis[N], t;
long long k;
int dfs(int v, int p) {
if (vis[v]) {
t = v;
return vis[p] - vis[v] + 1;
}
vis[v] = vis[p] + 1;
return dfs(a[v], v);
}
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
int... | #include <iostream>
using namespace std;
const int N = 2e5 + 10;
int a[N], n, vis[N], t;
long long k;
int dfs(int v, int p) {
if (vis[v]) {
t = v;
return vis[p] - vis[v] + 1;
}
vis[v] = vis[p] + 1;
return dfs(a[v], v);
}
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
int... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]] | 1 | 232 |
def main():
N, K, *A = map(int, open(0).read().split())
visited = [-1]*N
pos = A[0]
visited[0] = 0
visited[pos - 1] = 1
step = 2
order = 0
start = 0
step_to_start = 0
while True:
pos = A[pos - 1]
if visited[pos - 1] == -1:
visited[pos - 1] = step
... | def main():
N, K, *A = map(int, open(0).read().split())
visited = [-1]*N
pos = A[0]
visited[0] = 0
visited[pos - 1] = 1
step = 2
order = 0
start = 0
step_to_start = 0
while True:
pos = A[pos - 1]
if visited[pos - 1] == -1:
visited[pos - 1] = step
... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]] | 5 | 193 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long n;
long long k;
long c = 1;
cin >> n >> k;
vector<long> a(n), e(n), f(n, 0);
for (long i = 0; i < n; ++i) {
cin >> a[i];
}
long p = 0;
long q;
e[0] = 1;
f[0] = 1;
for (long i = 0; i < n; ++i) {
q = a[p] - 1;
if (f[q] =... | #include <bits/stdc++.h>
using namespace std;
int main() {
long n;
long long k;
long c = 1;
cin >> n >> k;
vector<long> a(n), e(n), f(n, 0);
for (long i = 0; i < n; ++i) {
cin >> a[i];
}
long p = 0;
long q;
e[0] = 1;
f[0] = 1;
for (long i = 0; i < n; ++i) {
q = a[p] - 1;
if (f[q] =... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 237 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
c = 0
d = {}
t = []
# 順番をdictで持つ
while not s in d.keys():
d[s] = c
t.append(s)
c += 1
s = a[s-1]
l = c - d[s]
m = len(d.keys()) - l
if m >= k:
print(t[m])
else:
print(t[(k - m) % l + m])
| n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
c = 0
d = {}
t = []
# 順番をdictで持つ
while not s in d.keys():
d[s] = c
t.append(s)
c += 1
s = a[s-1]
l = c - d[s]
m = len(d.keys()) - l
if m >= k:
print(t[k])
else:
print(t[(k - m) % l + m])
| [["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22]] | 5 | 130 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 60;
struct Doubling {
const int LOG;
vector<vector<int>> table;
Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_cl... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 60;
struct Doubling {
const int LOG;
vector<vector<int>> table;
Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_cl... | [["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]] | 1 | 346 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long LL;
int n, a[N], to[N][63], now;
LL k;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i], to[i][0] = a[i];
for (int k = 1; k <= 64; k++)
for (int i = 1; i <= n; i++)
to[i][k] = to[to[i][k - 1... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long LL;
int n, a[N], to[N][64], now;
LL k;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i], to[i][0] = a[i];
for (int k = 1; k <= 62; k++)
for (int i = 1; i <= n; i++)
to[i][k] = to[to[i][k - 1... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 197 |
import copy
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
count = [0]
Check = [0] * N
for i in range(K):
count.append(A[count[-1]]-1)
# print(count)
if(Check[count[-1]-1] == 1):
break
Check[count[-1]-1] = 1
i += 1
saisyo = count.index(count[-1]) + 1
#print(c... | import copy
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
count = [0]
Check = [0] * N
for i in range(K):
count.append(A[count[-1]]-1)
# print(count)
if(Check[count[-1]-1] == 1):
break
Check[count[-1]-1] = 1
i += 1
saisyo = count.index(count[-1]) + 1
#print(... | [["-", 3, 4, 0, 657, 31, 206, 206, 657, 17, 33], ["-", 3, 4, 0, 657, 31, 206, 206, 657, 12, 612]] | 5 | 186 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
vector<int> f(N), f_cp(N);
for (int i = 0; i < N; ++i) {
cin >> f[i];
--f[i];
f_cp[i] = f[i];
}
int now = 0;
while (K) {
if (K & 1)
now = f[now];
for (int i = 0; i < N; ++i)
f_cp[i] ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
vector<int> f(N), f_cp(N);
for (int i = 0; i < N; ++i) {
cin >> f[i];
--f[i];
f_cp[i] = f[i];
}
int now = 0;
while (K) {
if (K & 1)
now = f[now];
for (int i = 0; i < N; ++i)
f_cp[i] ... | [["+", 0, 11, 12, 69, 341, 342, 0, 69, 28, 22], ["+", 12, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 12, 69, 341, 342, 0, 69, 341, 342, 0, 73]] | 1 | 141 |
#167
#d
n,k = map(int, input().split())
ln = list(map(int, input().split()))# まちi にいるとき次に町ln[i-1]へいく
# n,k = 10*4,10**18
# ln = list(range(2,n+1))
# ln.append(1)
visit = [0]*n
now= 1 # 街iにいる
before =[] # ループに入る前(1回めのループ含む)
roop =[] # ループ内
while visit[now -1] != 2:
if visit[now -1] == 0:
before.append(no... | #167
#d
n,k = map(int, input().split())
ln = list(map(int, input().split()))# まちi にいるとき次に町ln[i-1]へいく
# n,k = 10*4,10**18
# ln = list(range(2,n+1))
# ln.append(1)
visit = [0]*n
now= 1 # 街iにいる
before =[] # ループに入る前(1回めのループ含む)
roop =[] # ループ内
while visit[now -1] != 2:
if visit[now -1] == 0:
before.append(no... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 158 |
# -*- coding: utf-8 -*-
N, K=map(int, input().split())
A = list(map(int,input().split()))
now=0
rireki=[0]*N
isou=1
hazimete=0
for i in range(4*N):
if rireki[now]==0:
rireki[now]=1
startnum=i
start=now
else:
if hazimete==1:
startnum=i
start=now
ha... | # -*- coding: utf-8 -*-
N, K=map(int, input().split())
A = list(map(int,input().split()))
now=0
rireki=[0]*N
isou=1
hazimete=0
for i in range(4*N):
if rireki[now]==0:
rireki[now]=1
startnum=i
start=now
else:
if hazimete==1:
startnum=i
start=now
ha... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 224 |
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl =... | #include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl =... | [["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22]] | 1 | 271 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.