Precreation contest files

This commit is contained in:
2026-02-11 11:28:23 +07:00
parent 0a8ea477bb
commit cb9f7cab30
134 changed files with 1848 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("search.inp", "r", stdin);
int n, x;
cin >> n >> x;
vector<int> a(n);
for (int &i : a)
cin >> i;
if (x - 1 > n || x < 0) {
cout << -1 << '\n';
return 0;
} else {
x = a[x - 1];
}
int cnt = 0;
for (int i = 0; i < n; i++) {
// cout << a[i] << '\n';
if (a[i] == x) {
cout << i + 1 << ' ';
cnt++;
}
}
cout << '\n';
cout << ((cnt == 0) ? -1 : cnt) << '\n';
}