Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- ll gcd(ll a, ll b){
- return (b ? gcd(b, a % b) : a);
- }
- ll lcm(ll a, ll b){
- return a / gcd(a, b) * b;
- }
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int n;
- cin >> n;
- int a[n];
- int f[500000];
- for (int i=0; i<500000; i++) {
- f[i]=-1;
- }
- for (int i=0; i<n; i++) {
- cin >> a[i];
- f[a[i]]=i;
- }
- int q;
- int s=0;
- cin >> q;
- while (q--) {
- int k,x;
- cin >> k >> x;
- if (k==1) {
- s+=x;
- s+=n;
- }
- else {
- if (f[x]!=-1)cout << (f[x]+s)%(n)+1 << endl;
- else cout << -1 << endl;
- }
- }
- return 0;
- }
- /*
- 1
- 6 24
- */
Advertisement
Add Comment
Please, Sign In to add comment