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 <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <se... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <se... | [["-", 51, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 12, 13]] | 1 | 495 |
import heapq
from collections import deque
T = int(input())
for t in range(T):
N,A,B,C,D = map(int,input().split())
q = [(0,N)]
heapq.heapify(q)
seen = set()
while q:
cost, n = heapq.heappop(q)
if n in seen:
continue
seen.add(n)
if n == 0:
pri... | import heapq
T = int(input())
for t in range(T):
N,A,B,C,D = map(int,input().split())
q = [(0,N)]
heapq.heapify(q)
seen = set()
while q:
cost, n = heapq.heappop(q)
if n in seen:
continue
seen.add(n)
if n == 0:
print(cost)
break
... | [["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["-", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22], ["-", 3, 4, 0, 660, 0, 657, 12, 657, 31, 22], ["+", 3, 4, 0, 660, 0, 657, 12, 657, 31, 22]] | 5 | 353 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 9223372036854775807; // MAX 9223372036854775807
int main() {
ll t;
cin >> t;
rep(i, t) {
ll n;
cin >> n;
ll a, b, c, d;
cin >> a >> b >> c >> d;
map<ll, ll> m;... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 9223372036854775807; // MAX 9223372036854775807
int main() {
ll t;
cin >> t;
rep(i, t) {
ll n;
cin >> n;
ll a, b, c, d;
cin >> a >> b >> c >> d;
map<ll, ll> m;... | [["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25]] | 1 | 732 |
#include <bits/stdc++.h>
using namespace std;
#define ll __int128
#define inf (ll)2333333333333333333
map<ll, ll> mp;
ll t, n, a, b, c, d;
inline ll rd() {
ll x = 0;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0... | #include <bits/stdc++.h>
using namespace std;
#define ll __int128
#define inf (ll)2333333333333333333
map<ll, ll> mp;
ll t, n, a, b, c, d;
inline ll rd() {
ll x = 0;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0... | [["+", 0, 34, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 34, 12, 2, 3, 4, 0, 16, 12, 13]] | 1 | 565 |
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)
t = int(input())
l = [list(map(int, input().split())) for i in range(t)]
for i in range(t):
N = l[i][0]
A = l[i][1]
B = l[i][2]
C = l[i][3]
D = l[i][4]
@lru_cache(maxsize=10**18)
def min_coin(n):
if(n == 0)... | import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)
t = int(input())
l = [list(map(int, input().split())) for i in range(t)]
for i in range(t):
N = l[i][0]
A = l[i][1]
B = l[i][2]
C = l[i][3]
D = l[i][4]
@lru_cache(maxsize=10**18)
def min_coin(n):
if(n == 0)... | [["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 676]] | 5 | 342 |
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
Dy[8] = {-1, -1, 0,... | //#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
Dy[8] = {-1, -1, 0,... | [["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 707 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return lis... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return lis... | [["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]] | 5 | 780 |
#include <queue>
#include <stdio.h>
using namespace std;
typedef unsigned long long ll;
int main(void) {
ll i, j, k, t, n, a, b, c, d, ans, x, y, z;
scanf("%lld", &t);
for (k = 0; k < t; ++k) {
scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
priority_queue<pair<ll, ll>> q;
pair<ll, ll> p;
ans ... | #include <queue>
#include <stdio.h>
using namespace std;
typedef unsigned long long ll;
int main(void) {
ll i, j, k, t, n, a, b, c, d, ans, x, y, z;
scanf("%lld", &t);
for (k = 0; k < t; ++k) {
scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
priority_queue<pair<ll, ll>> q;
pair<ll, ll> p;
ans ... | [["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13]] | 1 | 459 |
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
Int A, B, C, D;
map<Int, Int> m;
Int solve(Int N) {
if (N == 0)
return 0;
if (N == 1)
return D;
if (m.count(N))
return m[N];
Int l2 = (N / 2) * 2;
Int r2 = ((N + 1) / 2) * 2;
Int l3 = (N / 3) * 3;
Int r3 = ((N + 2) / 3) *... | #include <bits/stdc++.h>
using namespace std;
typedef long long Int;
Int A, B, C, D;
map<Int, Int> m;
Int solve(Int N) {
if (N == 0)
return 0;
if (N == 1)
return D;
if (m.count(N))
return m[N];
Int l2 = (N / 2) * 2;
Int r2 = ((N + 1) / 2) * 2;
Int l3 = (N / 3) * 3;
Int r3 = ((N + 2) / 3) *... | [["-", 0, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 12, 13]] | 1 | 387 |
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rer(i, a, b) for (int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), ... | #include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rer(i, a, b) for (int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 2, 3,... | 1 | 869 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, a, b, c, d;
map<ll, ll> memo;
ll solve(ll N) {
if (N == 0)
return 0;
if (N == 1)
return d;
if (memo.count(N))
return memo[N];
ll cal = 1e18;
ll l2 = (N / 2) * 2;
ll r2 = ((N + 1) / 2) * 2;
ll l3 = (N / 3) * 3;
ll r3 ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, a, b, c, d;
map<ll, ll> memo;
ll solve(ll N) {
if (N == 0)
return 0;
if (N == 1)
return d;
if (memo.count(N))
return memo[N];
ll cal = 1e18;
ll l2 = (N / 2) * 2;
ll r2 = ((N + 1) / 2) * 2;
ll l3 = (N / 3) * 3;
ll r3 ... | [["-", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22]] | 1 | 388 |
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
int N;
long long K;
cin >> N >> K;
vector<pair<int, bool>> tp(N);
tp[0].second = true;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
tp[i].first = A;
}
vector<int> roop(N, -1);
int count = 1, stop = 0;
i... | #include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
int N;
long long K;
cin >> N >> K;
vector<pair<int, bool>> tp(N);
tp[0].second = true;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
tp[i].first = A;
}
vector<int> roop(N, -1);
int count = 1, stop = 0;
i... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25]] | 1 | 249 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
int main() {
ll n, k, a[200010], now = 0, hoge = 0, r[200010], rlen = 0, rend = 0,
clen = 0, rstart = 0;
bool f[200010] = {false};
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> hoge;
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
int main() {
ll n, k, a[200010], now = 0, hoge = 0, r[200010], rlen = 0, rend = 0,
clen = 0, rstart = 0;
bool f[200010] = {false};
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> hoge;
... | [["-", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 276 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
... | [["-", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 70], ["-", 341, 342, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 341, 342, 0, 69, 341, 342, 0, 16, 12, 13], ["-", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]] | 1 | 345 |
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n);
for (int i = 1; i <= n; i++) {
cin >> a[i... | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 226 |
//事前知識:vectorは必須。(仕組みが知りたければ、エイリアステンプレート、auto型、範囲for文を調べることを推奨)
// macの場合は準備が必要。
//既存のXcodeに付属しているg++は古いケースも多いので、https://qiita.com/wawawa/items/50c2c612b0937f28d92b の通りにやって最新版を使えるようにする。
// 5行目はmacには標準装備されてないので、自分で用意する必要がある。https://qiita.com/flowerrr__lily/items/28a20062e957fa10b7a7 の通りにやろう。
//標準ライブラリの一括インストール
#includ... | //事前知識:vectorは必須。(仕組みが知りたければ、エイリアステンプレート、auto型、範囲for文を調べることを推奨)
// macの場合は準備が必要。
//既存のXcodeに付属しているg++は古いケースも多いので、https://qiita.com/wawawa/items/50c2c612b0937f28d92b の通りにやって最新版を使えるようにする。
// 5行目はmacには標準装備されてないので、自分で用意する必要がある。https://qiita.com/flowerrr__lily/items/28a20062e957fa10b7a7 の通りにやろう。
//標準ライブラリの一括インストール
#includ... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 2,348 |
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tup... | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tup... | [["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 18]] | 1 | 265 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n) {
for (int i = 0; i < n; i++)
cin >> a[i];
}
int main() {
int n;
ll k;
cin >> n >> k;
int a[n + 1];
int mita[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n) {
for (int i = 0; i < n; i++)
cin >> a[i];
}
int main() {
int n;
ll k;
cin >> n >> k;
int a[n + 1];
int mita[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i... | [["-", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 251 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
unsigned long long int k;
cin >> n >> k;
int a[n];
map<int, int> m;
vector<int> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int i = 1;
while (m.count(i) == 0) {
// cout<< i <<" ";
m[i] = 0;
v.push_back(i);
i =... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
unsigned long long int k;
cin >> n >> k;
int a[n];
map<int, int> m;
vector<int> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int i = 1;
while (m.count(i) == 0) {
// cout<< i <<" ";
m[i] = 0;
v.push_back(i);
i =... | [["+", 64, 9, 0, 1, 0, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 73]] | 1 | 214 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i, s, n) for (ll i = s; i <= n; i++)
#define ford(j, s, n) for (int i = n; i >= s; i--)
#define pb push_back
#define TEST ... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i, s, n) for (ll i = s; i <= n; i++)
#define ford(j, s, n) for (int i = n; i >= s; i--)
#define pb push_back
#define TEST ... | [["-", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22]] | 1 | 307 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n, x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x, y) (((x) + (y)-1) / (y))
i... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n, x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x, y) (((x) + (y)-1) / (y))
i... | [["-", 31, 118, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 118, 28, 69, 341, 342, 0, 16, 12, 13]] | 1 | 378 |
package main
import (
"fmt"
)
func main() {
var n, k int
fmt.Scanf("%d %d", &n, &k)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scanf("%d", &a[i])
a[i]--
}
answer := finalTown(n, k, a) + 1
fmt.Println(answer)
}
func finalTown(n, k int, a []int) int {
beforeLoop := 1
loopStart := 0
loopLength := 1... | package main
import (
"fmt"
)
func main() {
var n, k int
fmt.Scanf("%d %d", &n, &k)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scanf("%d", &a[i])
a[i]--
}
answer := finalTown(n, k, a) + 1
fmt.Println(answer)
}
func finalTown(n, k int, a []int) int {
beforeLoop := 1
loopStart := 0
loopLength := 1... | [["+", 0, 7, 0, 430, 15, 16, 12, 16, 17, 33], ["+", 0, 7, 0, 430, 15, 16, 12, 16, 12, 433]] | 7 | 338 |
nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]
t = 1
tl = [1]
ts = {1}
flg = False
for i in range(len(a)):
# flg = t > a[t-1]
t = a[t-1]
# stl = sorted(tl)
if t in ts:
break
else:
tl.append(t)
ts.add(t)
tl2 = tl[tl.index(t):len(t... | nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]
t = 1
tl = [1]
ts = {1}
for i in range(len(a)):
t = a[t-1]
if t in ts:
break
else:
tl.append(t)
ts.add(t)
tl2 = tl[tl.index(t):len(tl)]
# print(tl)
# print(tl2)
ans = 0
if k... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 147], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 166 |
#include <iostream>
using namespace std;
int main() {
long long int N, K;
cin >> N >> K;
long long int A[N];
for (long long int i = 0; i < N; i++)
cin >> A[i];
long long int count = 0;
bool flag[N];
for (int i = 0; i < N; i++)
flag[i] = false;
long long int now = 0;
long long int num[N];
f... | #include <iostream>
using namespace std;
int main() {
long long int N, K;
cin >> N >> K;
long long int A[N];
for (long long int i = 0; i < N; i++)
cin >> A[i];
long long int count = 0;
bool flag[N];
for (int i = 0; i < N; i++)
flag[i] = false;
long long int now = 0;
long long int num[N];
f... | [["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 286 |
def q4():
N, K = [int(i) for i in input().split(" ")]
A = [-1] + [int(i) for i in input().split(" ")]
arrived = []
arrived_set = set()
current = 1
loop_start_station = -1
while True:
arrived.append(current)
arrived_set.add(current)
current = A[current]
if cu... |
def q4():
N, K = [int(i) for i in input().split(" ")]
A = [-1] + [int(i) for i in input().split(" ")]
arrived = []
arrived_set = set()
current = 1
loop_start_station = -1
while True:
arrived.append(current)
arrived_set.add(current)
current = A[current]
if cu... | [["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38]] | 5 | 147 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
a[i]-=1
visit=[False for i in range(n)]
visit[0]=True
looplist=[False for i in range(n)]
mark=-1
i=0
num=0
loop=0
count=0
while True:
num+=1
i=a[i]
if mark<0 and visit[i]:
mark=a[i]
else:
visit[i]=True
if mark>-1 and lo... | n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
a[i]-=1
visit=[False for i in range(n)]
visit[0]=True
looplist=[False for i in range(n)]
mark=-1
i=0
num=0
loop=0
count=0
while True:
num+=1
i=a[i]
if mark<0 and visit[i]:
mark=a[i]
else:
visit[i]=True
if mark>-1 and lo... | [["-", 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, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 209 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <util... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <util... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18]] | 1 | 297 |
#include <bits/stdc++.h>
using namespace std;
long long n, k;
long a[2000100];
long long t = 0;
long long b[2000100];
long long p = 1;
int main() {
cin >> n >> k;
for (long long i = 0; i < n; i++)
cin >> a[i + 1];
for (long long i = 1; i <= n; i++)
b[i] = 0;
// cout << "data "<<endl;
t = k;
... | #include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[2000100];
long long t = 0;
long long b[2000100];
long long p = 1;
int main() {
cin >> n >> k;
for (long long i = 0; i < n; i++)
cin >> a[i + 1];
for (long long i = 1; i <= n; i++)
b[i] = 0;
// cout << "data "<<endl;
t = ... | [["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 199 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k, i, j;
cin >> n >> k;
vector<ll> a(n + 1);
for (i = 1; i <= n; i++) {
cin >> a[i];
}
vector<ll> canvisit(200010, 0);
ll keynum = a[1];
for (i = 1; i <= 3 * n + 1; i++) { //訪れない町は0
canvisit[keynum]++;
ke... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k, i, j;
cin >> n >> k;
vector<ll> a(n + 1);
for (i = 1; i <= n; i++) {
cin >> a[i];
}
vector<ll> canvisit(200010, 0);
ll keynum = a[1];
for (i = 1; i <= 3 * n + 1; i++) { //訪れない町は0
canvisit[keynum]++;
ke... | [["+", 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]] | 1 | 298 |
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll N, K;
// vector <ull> A;
ll Am[200001] = {
-1,
};
ll vcount[200001] = {
0,
};
ll istep[200001] = {
-1,
};
ll Dest[200001] = {
-1,
};
int main() {
ll i, j;
l... | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll N, K;
// vector <ull> A;
ll Am[200001] = {
-1,
};
ll vcount[200001] = {
0,
};
ll istep[200001] = {
-1,
};
ll Dest[200001] = {
-1,
};
int main() {
ll i, j;
l... | [["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 351 |
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long lo... | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long lo... | [["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]] | 1 | 266 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define endl "\n"
#define loop(i, s, e) for (int i = s; i < e; i++)
#define int long long
#define vi vector<int>
#define S(v) sort(v... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define endl "\n"
#define loop(i, s, e) for (int i = s; i < e; i++)
#define int long long
#define vi vector<int>
#define S(v) sort(v... | [["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 399 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007; //出力は (ans % mod + mod) % mod (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007; //出力は (ans % mod + mod) % mod (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 12, 16, 31, 23, 0, 16, 12, 74, 0, 24], ["+", 31, 23, 0, 16, 12, 74, 39, 77, 39, 78], ["+", 12, 16, 31, 23, 0, 16, 12, 74, 0, 25]] | 1 | 321 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
map<ll, ll> m;
for (ll i = 0; i < n; i++) {
ll mm;
cin >> mm;
m[i] = --mm;
}
// k <= n のときは素直に探索しても間に合う。
if (k <= n) {
ll machi = 0;
for (ll i = 0; i < k; i++) {
machi = m[m... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
map<ll, ll> m;
for (ll i = 0; i < n; i++) {
ll mm;
cin >> mm;
m[i] = --mm;
}
// k <= n のときは素直に探索しても間に合う。
if (k <= n) {
ll machi = 0;
for (ll i = 0; i < k; i++) {
machi = m[m... | [["-", 0, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 397 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
using namespace std;
int main() {
ll N, K;
ll ans = 0;
cin >> N >> K;
vector<ll> A(N + 100, 0);
vector<ll> seen(N + 100, -1);
for (ll i = 0; i < N; i++) {
... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
using namespace std;
int main() {
ll N, K;
ll ans = 1;
cin >> N >> K;
vector<ll> A(N + 100, 0);
vector<ll> seen(N + 100, -1);
for (ll i = 0; i < N; i++) {
... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 252 |
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
ll a[n];
for (ll i = 0; i < n; i++) {
ll p;
cin >> p;
p--;
a[i] = p;
}
ll now = 0;
vector<ll> route;
map<ll, ll> visited;
route.push_back(now)... | #include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
ll a[n];
for (ll i = 0; i < n; i++) {
ll p;
cin >> p;
p--;
a[i] = p;
}
ll now = 0;
vector<ll> route;
map<ll, ll> visited;
route.push_back(now)... | [["+", 64, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 64, 1, 0, 16, 31, 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 | 263 |
#include <stdio.h>
#define ll long long
ll town[200005];
ll flag[200005];
int main() {
ll N, K;
ll i;
scanf("%lld %lld", &N, &K);
for (i = 1; i <= N; i++)
scanf("ll%d", &town[i]);
for (i = 1; i <= N; i++)
flag[i] = 0;
/***********************************************寻找第一个重复出现的镇*******************... | #include <stdio.h>
#define ll long long
ll flag[200005];
ll town[200005];
int main() {
ll N, K;
ll i;
scanf("%lld %lld", &N, &K);
for (i = 1; i <= N; i++)
scanf("%lld", &town[i]);
for (i = 1; i <= N; i++)
flag[i] = 0;
/***********************************************寻找第一个重复出现的镇********************... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 49, 22], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 49, 22], ["-", 8, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 273 |
#include <bits/stdc++.h>
#define ll long long
#define pii_ pair<int, int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define show1(a) cout << #a << " = " << a << endl
#define show2(a, b) cout << #a << " = " << a << "; " << #b << " ... | #include <bits/stdc++.h>
#define ll long long
#define pii_ pair<int, int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define show1(a) cout << #a << " = " << a << endl
#define show2(a, b) cout << #a << " = " << a << "; " << #b << " ... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 299 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class cycle_finder {
public:
vector<vector<int>> adj;
vector<int> visit_state;
vector<int> parent;
... | #include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class cycle_finder {
public:
vector<vector<int>> adj;
vector<int> visit_state;
vector<int> parent;
... | [["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]] | 1 | 621 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long N, K;
... | #include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long N, K;
... | [["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]] | 1 | 339 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
vector<int> p(N);
for (int i = 0; i < N; i++) {
int a;
cin >> a;
a--;
p.at(i) = a;
}
vector<int> Z(N, -1);
vector<int> q(N);
int b = 0;
Z.at(0) = 0;
int64_t c = 1;
q.at(0) = 0;
while (true) {... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
vector<int> p(N);
for (int i = 0; i < N; i++) {
int a;
cin >> a;
a--;
p.at(i) = a;
}
vector<int> Z(N, -1);
vector<int> q(N);
int b = 0;
Z.at(0) = 0;
int64_t c = 1;
q.at(0) = 0;
while (true) {... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 253 |
#include <iostream>
#include <vector>
using namespace std;
using ull = unsigned long long;
int main(void) {
ull N, K;
cin >> N >> K;
vector<ull> A(N);
for (auto &a : A) {
cin >> a;
a--;
}
vector<ull> vis(N, 0);
ull cnt = 1;
ull i = 0;
do {
vis[i] = cnt;
cnt++;
i = A[i];
} while ... | #include <iostream>
#include <vector>
using namespace std;
using ull = unsigned long long;
int main(void) {
ull N, K;
cin >> N >> K;
vector<ull> A(N);
for (auto &a : A) {
cin >> a;
a--;
}
vector<ull> vis(N, 0);
ull cnt = 1;
ull i = 0;
do {
vis[i] = cnt;
cnt++;
i = A[i];
} while ... | [["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 73]] | 1 | 185 |
import sys
n, k = map(int, input().split())
l = list(map(int, input().split()))
count = 0
li = [0 for _ in range(n)]
b = 1
for i in range(1,n + 1):
# print(b)
if li[b-1] != 0:
break
li[b-1] = i
b = l[b-1]
count += 1
# print('count',count)
d = count - li[b-1] + 1
intercep = li[b-1] -1
#... | import sys
n, k = map(int, input().split())
l = list(map(int, input().split()))
count = 0
li = [0 for _ in range(n)]
b = 1
for i in range(1,n + 1):
# print(b)
if li[b-1] != 0:
break
li[b-1] = i
b = l[b-1]
count += 1
# print('count',count)
d = count - li[b-1] + 1
intercep = li[b-1] -1
#... | [["+", 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 | 185 |
n,k = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
flag = [False] * n
town = 1
towns = [1]
flag[0] = True
while(True):
ntown = A[town-1]
if flag[ntown-1]:
l_s = towns.index(ntown)
if k < l_s:
print(towns[k-1])
break
else:
... | n,k = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
flag = [False] * n
town = 1
towns = [1]
flag[0] = True
while(True):
ntown = A[town-1]
if flag[ntown-1]:
l_s = towns.index(ntown)
if k < l_s:
print(towns[k])
break
else:
... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 147 |
/* ###########################
# Author : Pranay Garg #
# College : SGSITS #
###########################
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
#define ull unsigned long long int
#define ironman ... | /* ###########################
# Author : Pranay Garg #
# College : SGSITS #
###########################
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
#define ull unsigned long long int
#define ironman ... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 1,665 |
import collections
import numpy as np
import sys
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
A[i]-=1
B=[0]
visited=[0]*N
visited[0]=1
Flag=True
for i in range(0,N*2):
next=A[B[i]]
if visited[next]==0:
B.append(next)
visited[next]=1
else:
... | import collections
import numpy as np
import sys
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
A[i]-=1
B=[0]
visited=[0]*N
visited[0]=1
Flag=True
for i in range(0,N*2):
next=A[B[i]]
if visited[next]==0:
B.append(next)
visited[next]=1
else:
... | [["-", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 181 |
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#includ... | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#includ... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 3,591 |
#include <bits/stdc++.h>
#define range(i, l, r) for (long long int(i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int(i) = (r)-1; (i) >= l; (i)--)
using namespace std;
template <typename T> using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int... | #include <bits/stdc++.h>
#define range(i, l, r) for (long long int(i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int(i) = (r)-1; (i) >= l; (i)--)
using namespace std;
template <typename T> using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 952 |
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 111;
#define ll long long
int n, a[maxn], vis[maxn];
ll k;
vector<int> q;
int main() {
scanf("%d %lld", &n, &k);
for (int i = 1; i <= n; i++)
... | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 111;
#define ll long long
int n, a[maxn], vis[maxn];
ll k;
vector<int> q;
int main() {
scanf("%d %lld", &n, &k);
for (int i = 1; i <= n; i++)
... | [["-", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 230 |
#include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long n, ... | #include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long n, ... | [["+", 64, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 12, 13]] | 1 | 218 |
#!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
A[i] -= 1
tele = [0]
#tele = [0,A[0]-1]
z = 0
s = 0
#B = {0:0,A[0]-1:1}
B = {0:0}
for i in range(N):
if A[tele[-1]] in B and len(B) != 1:
s = B[A[tele[-1]]]
break
B[A[tele[-1]]] ... | #!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
A[i] -= 1
tele = [0]
#tele = [0,A[0]-1]
z = 0
s = 0
#B = {0:0,A[0]-1:1}
B = {0:0}
for i in range(N):
if A[tele[-1]] in B and len(B) != 1:
s = B[A[tele[-1]]]
break
B[A[tele[-1]]] ... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 201 |
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, in... | import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, in... | [["-", 0, 14, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 0, 14, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72]] | 5 | 659 |
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int main() {
ll n, k;
cin... | #include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int main() {
ll n, k;
cin... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 248 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i,... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i,... | [["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 286 |
import numpy as np
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
town_list = [0]*n
town_list[0] = 1
tn_list = [1]
while(1):
next = a[now-1]
now = next
if town_list[now-1] == 0:
town_list[now-1] = 1
tn_list.append(now)
else:
idx =... | import numpy as np
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
town_list = [0]*n
town_list[0] = 1
tn_list = [1]
while(1):
next = a[now-1]
now = next
if town_list[now-1] == 0:
town_list[now-1] = 1
tn_list.append(now)
else:
idx =... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20]] | 5 | 164 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll IN... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll IN... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]] | 1 | 1,619 |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
int n;
ull k;
scanf("%d %llu", &n, &k);
int a[n];
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
unordered_map<int, bool> visited;
int buffer[n];
visited[1] = true;
buffer[0] = 1;
int index = 1;
ull j ... | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
int n;
ull k;
scanf("%d %llu", &n, &k);
int a[n];
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
unordered_map<int, bool> visited;
int buffer[n];
visited[1] = true;
buffer[0] = 1;
int index = 1;
ull j ... | [["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 275 |
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for ... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for ... | [["-", 0, 656, 0, 57, 64, 196, 0, 1, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 270 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> P1;
typedef pair<P, P> P2;
#define pu ... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> P1;
typedef pair<P, P> P2;
#define pu ... | [["-", 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 | 371 |
// created by mtnshh
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repb(i, a, b) for (ll i = a; i >= b; i--)
#define err() cout << "==================================" << endl;
#define errA(A) ... | // created by mtnshh
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repb(i, a, b) for (ll i = a; i >= b; i--)
#define err() cout << "==================================" << endl;
#define errA(A) ... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 363 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long k = sc.nextLong();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++)
arr[i] = sc.nextInt();
int fast = 1;
int slow = 1;
long m... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long k = sc.nextLong();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++)
arr[i] = sc.nextInt();
int fast = 1;
int slow = 1;
long m... | [["-", 75, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 75, 196, 0, 1, 0, 492, 3, 4, 0, 22]] | 3 | 235 |
from sys import stdin
import numpy as np
def main():
N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
X = 1
L = [1]
if A[0] == 1:
print(1)
if N >= K :
for i in range(K):
X = A[X-1]
print(X)
... | from sys import stdin
import numpy as np
def main():
N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
X = 1
L = [1]
if A[0] == 1:
print(1)
exit()
if N >= K :
for i in range(K):
X = A[X-1]
... | [["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 228 |
import collections
def getls():
return [ipt for ipt in input().split()]
def getlsi():
return [int(ipt) for ipt in input().split()]
[n,k] = getlsi()
a = getlsi()
dic = collections.defaultdict(int)
now = 1
cnt = 1
while dic[now] == 0:
dic[now] = cnt
now = a[now-1]
cnt += 1
lp = cnt - dic[now]
if ... | import collections
def getls():
return [ipt for ipt in input().split()]
def getlsi():
return [int(ipt) for ipt in input().split()]
[n,k] = getlsi()
a = getlsi()
dic = collections.defaultdict(int)
now = 1
cnt = 1
while dic[now] == 0:
dic[now] = cnt
now = a[now-1]
cnt += 1
lp = cnt - dic[now]
if ... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 186 |
package main
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"strconv"
"strings"
)
type Input struct {
lines [][]string // Input は複数行からなる文字列から値をいい感じに取り出すためのメソッドを提供します.
}
func (i *Input) GetFirstAndSecondInt64Value(rowIndex int) (int64, int64, error) {
first, err := i.GetInt64Value(rowIndex, 0)
if err != nil {
... | package main
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"strconv"
"strings"
)
type Input struct {
lines [][]string // Input は複数行からなる文字列から値をいい感じに取り出すためのメソッドを提供します.
}
func (i *Input) GetFirstAndSecondInt64Value(rowIndex int) (int64, int64, error) {
first, err := i.GetInt64Value(rowIndex, 0)
if err != nil {
... | [["-", 0, 435, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 17, 18]] | 7 | 1,232 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_s... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_s... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 275 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int n_copy = n;
long k = sc.nextLong();
// long h = k%n;
long k_copy = k;
// System.out.println(h);
int[] arr = new int[n + 1];
for (int i = 1... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int n_copy = n;
long k = sc.nextLong();
// long h = k%n;
long k_copy = k;
// System.out.println(h);
int[] arr = new int[n + 1];
for (int i = 1... | [["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]] | 3 | 324 |
/*
6 5 2 5 3 2
1->6->2->5->3->2->5->3
3 2 4 1
1->3->4->1->3->4
2 3 4 5 1
1->2->3->4->5->1
*/
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1 << 30;
const ll MOD = 1e9 + 7;
int main() {
int n, a[200005], pos[200005];
... | /*
6 5 2 5 3 2
1->6->2->5->3->2->5->3
3 2 4 1
1->3->4->1->3->4
2 3 4 5 1
1->2->3->4->5->1
*/
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1 << 30;
const ll MOD = 1e9 + 7;
int main() {
int n, a[200005], pos[200005];
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]] | 1 | 282 |
// Author : Sukarna Paul
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS \
ios::sync_with_st... | // Author : Sukarna Paul
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS \
ios::sync_with_st... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 455 |
n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n*2):
if timestamp[position-1] != 0:
start = timestamp[position-1]
period = i-timestamp[position-1]
break
timestamp[position-1] =i
position = a[position-1]
if k <=... | n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n*2):
if timestamp[position-1] != 0:
start = timestamp[position-1]
period = i-timestamp[position-1]
break
timestamp[position-1] =i
position = a[position-1]
if k <=st... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 165 |
import sys
sys.setrecursionlimit(10**6)
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}
def f(L, S):
last = L[-1]-1
if A[last] not in S:
L.append(A[last])
S |= {last}
return f(L, S)
else:
return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)... | import sys
sys.setrecursionlimit(10**6)
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}
def f(L, S):
last = L[-1]-1
if A[last] not in S:
L.append(A[last])
S |= {A[last]}
return f(L, S)
else:
return L
P = f(L, S)
a = A[P[-1]-1]
j = P.inde... | [["+", 0, 1, 0, 677, 12, 282, 0, 206, 51, 22], ["+", 0, 1, 0, 677, 12, 282, 0, 206, 0, 70], ["+", 0, 1, 0, 677, 12, 282, 0, 206, 0, 73]] | 5 | 174 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 255 |
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as... | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as... | [["+", 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 | 210 |
import sys
sys.setrecursionlimit(10**6)
def f(x,dic,i):
p=dic1[x]
if p in dic:
return [dic,p]
else:
dic[p]=i
return f(p,dic,i+1)
def inv(x,dic):
for k,v in dic.items():
if v==x:
return k
n,k=map(int,input().split())
m=[i for i in range(n)]
l=list(map(int,inp... | import sys
sys.setrecursionlimit(10**6)
def f(x,dic,i):
p=dic1[x]
if p in dic:
return [dic,p]
else:
dic[p]=i
return f(p,dic,i+1)
def inv(x,dic):
for k,v in dic.items():
if v==x:
return k
n,k=map(int,input().split())
m=[i for i in range(n)]
l=list(map(int,inp... | [["-", 0, 657, 31, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 657, 31, 652, 3, 4, 0, 657, 17, 33]] | 5 | 257 |
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
l.append(i)
if i not in visited:
visited.add(i)
else:
break
i=d[i]
first=l.index(l[-1])
if k<first:
... | from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
l.append(i)
if i not in visited:
visited.add(i)
else:
break
i=d[i]
first=l.index(l[-1])
if k<first:
... | [["-", 12, 657, 31, 23, 0, 657, 31, 652, 63, 22], ["-", 31, 23, 0, 657, 31, 652, 3, 4, 0, 24], ["-", 31, 23, 0, 657, 31, 652, 3, 4, 0, 22], ["-", 31, 23, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 31, 22]] | 5 | 163 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n + 1);
vector<ll> aa;
set<ll> st;
set<ll> st2;
vector<ll> loop;
ll loop_cnt =... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> a(n + 1);
vector<ll> aa;
set<ll> st;
set<ll> st2;
vector<ll> loop;
ll loop_cnt =... | [["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22]] | 1 | 287 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0)
// *start on @date: 2020-05-10 21:19
const ll N = 2e5 + 5;
int n, a[N], v[N]... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0)
// *start on @date: 2020-05-10 21:19
const ll N = 2e5 + 5;
int n, a[N], v[N]... | [["-", 8, 9, 0, 82, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 82, 15, 23, 0, 16, 17, 79]] | 1 | 189 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = 1000000000000000000, mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m;
cin >> n >> m;
ll arr[n], vis[n + 1] = {0};
vector<ll> ans[n + 1], anss;
for (ll i = 0; i < n; i++) {
cin >> arr[i... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = 1000000000000000000, mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m;
cin >> n >> m;
ll arr[n], vis[n + 1] = {0};
vector<ll> ans[n + 1], anss;
for (ll i = 0; i < n; i++) {
cin >> arr[i... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13]] | 1 | 259 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A)) # 0-indexed
pos = 0
memo = [[False, 0] for _ in range(N)] # memo[i]: [bool, tel_cnt] , [数えたか、何回移動したか]
memo[0] = [True, 0]
distance = 0
l_pos = 0
tel_cnt = 0
while True:
next = A[pos]
tel_cnt += 1
if memo[... | N, K = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A)) # 0-indexed
pos = 0
memo = [[False, 0] for _ in range(N)] # memo[i]: [bool, tel_cnt] , [数えたか、何回移動したか]
memo[0] = [True, 0]
distance = 0
l_pos = 0
tel_cnt = 0
while True:
next = A[pos]
tel_cnt += 1
if memo[... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 234 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T ... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 417 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a =... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a =... | [["-", 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], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 384 |
#include <stdio.h>
int n, a[200000], r, t[200000], i;
long long k, q;
int main() {
scanf("%d%lld", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
t[i] = -1;
}
r = 1;
i = 0;
while (t[r - 1] == -1) {
t[r - 1] = i++;
r = a[r - 1];
}
if (k < i)
q = t[r - 1];
else
q = (k - t... | #include <stdio.h>
int n, a[200000], r, t[200000], i;
long long k, q;
int main() {
scanf("%d%lld", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
t[i] = -1;
}
r = 1;
i = 0;
while (t[r - 1] == -1) {
t[r - 1] = i++;
r = a[r - 1];
}
if (k < i)
q = k;
else
q = (k - t[r - 1]... | [["-", 0, 57, 64, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 57, 64, 1, 0, 11, 12, 69, 0, 70], ["-", 64, 1, 0, 11, 12, 69, 71, 16, 31, 22], ["-", 64, 1, 0, 11, 12, 69, 71, 16, 17, 33], ["-", 64, 1, 0, 11, 12, 69, 71, 16, 12, 13], ["-", 0, 57, 64, 1, 0, 11, 12, 69, 0, 73], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22]] | 0 | 204 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a] # 入力値を添字に合わせる
path = [] # 通った道を記録。通過済みのところに到達したら記録中止
now = 0
visited = [False] * n
while not visited[now]:
path.append(now)
visited[now] = True
now = a[now]
# sはループの開始地点の添字
# whileループが終わった時点のnowには、堂々巡りの開始地点の添字が入っている
... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a] # 入力値を添字に合わせる
path = [] # 通った道を記録。通過済みのところに到達したら記録中止
now = 0
visited = [False] * n
while not visited[now]:
path.append(now)
visited[now] = True
now = a[now]
# sはループの開始地点の添字
# whileループが終わった時点のnowには、堂々巡りの開始地点の添字が入っている
... | [["+", 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], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 131 |
n,k=map(int,input().split())
a=list(map(int,input().split()))
l1=[0]*n
l1[0]+=1
c=0 #ループに入る前までの移動回数
now=0#現在位置
ne=a[now]-1 #次の移動位置
while True:
if c==k:
print(now+1)
exit()
if l1[ne]==0:
l1[ne]+=1
now=ne
ne=a[now]-1
c+=1
else:
now=ne
ne=a[now]-1... | n,k=map(int,input().split())
a=list(map(int,input().split()))
l1=[0]*n
l1[0]+=1
c=0 #ループに入る前までの移動回数
now=0#現在位置
ne=a[now]-1 #次の移動位置
while True:
if c==k:
print(now+1)
exit()
if l1[ne]==0:
l1[ne]+=1
now=ne
ne=a[now]-1
c+=1
else:
now=ne
ne=a[now]-1... | [["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]] | 5 | 232 |
#include <algorithm>
#include <iostream>
#include <vector>
int main(int argc, char *argv[]) {
long long n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a.at(i);
}
std::vector<int> s, visited(n + 1, -1);
int v = 1;
while (visited.at(v) == -1) {
visited... | #include <algorithm>
#include <iostream>
#include <vector>
int main(int argc, char *argv[]) {
long long n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a.at(i);
}
std::vector<int> s, visited(n + 1, -1);
int v = 1;
while (visited.at(v) == -1) {
visited... | [["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72]] | 1 | 211 |
import sys
sys.setrecursionlimit(300000)
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
N, K = MI()
A = LMI()
d = dict()
seen = set()
i = 0
cur = 0
while True:
i... | import sys
sys.setrecursionlimit(300000)
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
N, K = MI()
A = LMI()
d = dict()
seen = set()
i = 0
cur = 0
while True:
i... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 250 |
n, k = map(int,input().split())
a = list(map(int,input().split()))
s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
s[now] = t
now = a[now] - 1
c.append(now+1)
t += 1
start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)
if k < cycle:
print(c[k])
else:
k -= start_cycle... | n, k = map(int,input().split())
a = list(map(int,input().split()))
s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
s[now] = t
now = a[now] - 1
c.append(now+1)
t += 1
start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)
if k < start_cycle:
print(c[k])
else:
k -= start... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 140 |
n,k=map(int,input().split())
a=[int(i)-1 for i in input().split()]
p=0
visited=[0]*n
first=[]
roop=[]
while visited[p]!=2:#二回通っていたらやめる
if visited[p]==0:#初めて通った
first.append(p)
else:#一回通った
roop.append(p)
visited[p]+=1#通った跡をつける
p=a[p]#テレポート
print(first,roop)
if len(first)>k:#一回もループしていないのなら... | n,k=map(int,input().split())
a=[int(i)-1 for i in input().split()]
p=0
visited=[0]*n
first=[]
roop=[]
while visited[p]!=2:#二回通っていたらやめる
if visited[p]==0:#初めて通った
first.append(p)
else:#一回通った
roop.append(p)
visited[p]+=1#通った跡をつける
p=a[p]#テレポート
if len(first)>k:#一回もループしていないのなら
print(first[k... | [["-", 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, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 157 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se se... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se se... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 415 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1 << 30)
#define LINF (1LL << 60)
#define EPS... | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1 << 30)
#define LINF (1LL << 60)
#define EPS... | [["+", 64, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 64, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 276 |
/* _/ _/ _/_/_/ _/
_/_/_/_/ _/_/ _/_/_/_/ _/_/ _/ _/_/
_/ _/ _/ _/ _/ _/ _/_/_/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/ _/_/ _/_/ _/_/ _/_/ _/ */
#include <algorithm>
#include <cmath>
#include <iomanip>
... | /* _/ _/ _/_/_/ _/
_/_/_/_/ _/_/ _/_/_/_/ _/_/ _/ _/_/
_/ _/ _/ _/ _/ _/ _/_/_/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/ _/_/ _/_/ _/_/ _/_/ _/ */
#include <algorithm>
#include <cmath>
#include <iomanip>
... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 364 |
n, k = map(int, input().split())
A = list(map(int, input().split()))
D = [1]
seen = [0]*n
seen[0] = 1
now = 0
while True:
now = A[now] - 1
D.append(now+1)
if seen[now]:
break
seen[now] = 1
f = D.index(D[-1])
if k < f:
print(D[k-1])
else:
cycle = len(D) - f - 1
k -= f
print(D[f + ... | n, k = map(int, input().split())
A = list(map(int, input().split()))
D = [1]
seen = [0]*n
seen[0] = 1
now = 0
while True:
now = A[now] - 1
D.append(now+1)
if seen[now]:
break
seen[now] = 1
f = D.index(D[-1])
if k < f:
print(D[k])
else:
cycle = len(D) - f - 1
k -= f
print(D[f + k%... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 140 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define int long long
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(N... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define int long long
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(N... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]] | 1 | 312 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
visited = [0]
for _ in range(n):
now = a[visited[-1]]-1
visited.append(now)
if k <= n:
print(visited[-1])
else:
p = visited.index(visited[-1])
loop = visited[::-1][1:].index(visited[-1])+1
x = (k-p-1)%loop
print(visited[p+... | n, k = map(int, input().split())
a = list(map(int, input().split()))
visited = [0]
for _ in range(n):
now = a[visited[-1]]-1
visited.append(now)
if k < n:
print(visited[k]+1)
else:
p = visited.index(visited[-1])
loop = visited[::-1][1:].index(visited[-1])+1
x = (k-p-1)%loop
print(visited[p+... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["-", 0, 652, 3, 4, 0, 206, 206, 664, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 664, 28, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, ... | 5 | 139 |
#include <bits/stdc++.h>
#define pb push_back
#define ef(i, u) for (int i = b[u]; i; i = nxt[i])
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, b, a) for (int i = b; i >= a; --i)
#define gcd(a, b) __gcd(a, b)
#define MEM(a, x) memset(a, x, sizeof(a))
#define VI vector<int>
#define PII pair<int, int>
#... | #include <bits/stdc++.h>
#define pb push_back
#define ef(i, u) for (int i = b[u]; i; i = nxt[i])
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, b, a) for (int i = b; i >= a; --i)
#define gcd(a, b) __gcd(a, b)
#define MEM(a, x) memset(a, x, sizeof(a))
#define VI vector<int>
#define PII pair<int, int>
#... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 360 |
N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]
index = [-1]*N
path = []
pre = 0
while index[pre] < 0:
index[pre] = len(path)
path += [pre]
pre = A[pre]
one = index[pre]
loops = len(path) - one
if K < one: print(path[K])
else: print(path[(K-one) % loops + one]+1)
| N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]
index = [-1]*N
path = []
pre = 0
while index[pre] < 0:
index[pre] = len(path)
path += [pre]
pre = A[pre]
one = index[pre]
loops = len(path) - one
if K < one: print(path[K]+1)
else: print(path[(K-one) % loops + one]+1)
| [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 129 |
def main1
n,k = gets.chomp.split(/ /).map {|i| i.to_i}
as = gets.chomp.split(/ /).map {|i| i.to_i}
as.unshift(0)
pos = 1
vs = []
vs[pos] = 0
ps = []
ps << pos
n = 1
while true
pos = as[pos]
ps << pos
if vs[pos]
loop_start_idx = vs[pos]
break
end
vs[pos] = n
... | def main1
n,k = gets.chomp.split(/ /).map {|i| i.to_i}
as = gets.chomp.split(/ /).map {|i| i.to_i}
as.unshift(0)
pos = 1
vs = []
vs[pos] = 0
ps = []
ps << pos
n = 1
while true
pos = as[pos]
ps << pos
if vs[pos]
loop_start_idx = vs[pos]
break
end
vs[pos] = n
n ... | [["-", 64, 749, 0, 662, 12, 742, 0, 738, 17, 33], ["-", 64, 749, 0, 662, 12, 742, 0, 738, 12, 612]] | 4 | 240 |
// ABC_167_D
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> v(n, 0);
for (ll i = 0; i < n; ++i) {
cin >> v.at(i);
--v[i];
}
set<int> s_used;
vector<int> v_path;
int now = 0;
while (s_used.count(now) == 0) {
v_path.p... | // ABC_167_D
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> v(n, 0);
for (ll i = 0; i < n; ++i) {
cin >> v.at(i);
--v[i];
}
set<int> s_used;
vector<int> v_path;
int now = 0;
while (s_used.count(now) == 0) {
v_path.p... | [["-", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 69, 28, 22]] | 1 | 211 |
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
//<editor-fold desc="definitions">
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll = ... | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
//<editor-fold desc="definitions">
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll = ... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]] | 1 | 1,064 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 10, mod = 1e9 + 7;
int ans[2 * N], a[N], t = 0, mark[N], lst;
void dfs(int v, int num) {
if (mark[v] == 2)
return;
lst = num;
ans[num] = v;
if (mark[v] == 1) {
mark[v]++;
t++;
}
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 10, mod = 1e9 + 7;
int ans[2 * N], a[N], t = 0, mark[N], lst;
void dfs(int v, int num) {
if (mark[v] == 2)
return;
lst = num;
ans[num] = v;
if (mark[v] == 1) {
mark[v]++;
t++;
}
... | [["-", 0, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 16, 31, 69, 341, 342, 0, 22]] | 1 | 294 |
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int b;
cin >> b;
a[i] = b - 1;
}
vector<int> flag(n, -1);
int tmp = 0;
int roop;
int i = 0;
while (k ... | #include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int b;
cin >> b;
a[i] = b - 1;
}
vector<int> flag(n, -1);
int tmp = 0;
int roop;
int i = 0;
while (k ... | [["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 195 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.