lina_os

Untitled

Feb 24th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. ll gcd(ll a, ll b){
  7. return (b ? gcd(b, a % b) : a);
  8. }
  9. ll lcm(ll a, ll b){
  10. return a / gcd(a, b) * b;
  11. }
  12.  
  13. int main() {
  14. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  15. int n;
  16. cin >> n;
  17. int a[n];
  18. int f[500000];
  19. for (int i=0; i<500000; i++) {
  20. f[i]=-1;
  21. }
  22. for (int i=0; i<n; i++) {
  23. cin >> a[i];
  24. f[a[i]]=i;
  25. }
  26. int q;
  27. int s=0;
  28. cin >> q;
  29. while (q--) {
  30. int k,x;
  31. cin >> k >> x;
  32. if (k==1) {
  33. s+=x;
  34. s+=n;
  35. }
  36. else {
  37. if (f[x]!=-1)cout << (f[x]+s)%(n)+1 << endl;
  38. else cout << -1 << endl;
  39. }
  40. }
  41. return 0;
  42. }
  43.  
  44. /*
  45. 1
  46. 6 24
  47.  
  48. */
Advertisement
Add Comment
Please, Sign In to add comment