fork download
  1. #pragma GCC optimize("Ofast,unroll-loops")
  2. #include <bits/stdc++.h>
  3. #pragma GCC target("avx2,popcnt")
  4.  
  5. using namespace std;
  6.  
  7. signed main() {
  8. // freopen("in.txt", "r", stdin);
  9. cin.tie(0)->sync_with_stdio(0);
  10. int g;
  11. cin >> g;
  12. int n, q;
  13. cin >> n >> q;
  14. vector<int> a(n);
  15. for (auto &it : a) cin >> it;
  16. while (q--) {
  17. int l, x;
  18. cin >> l >> x;
  19. --l;
  20. vector<int> ans;
  21. bitset<5010> cur;
  22. cur.set();
  23. cur[0] = 0;
  24. for (int i = l; i < n; ++i) {
  25. cur[a[i]] = 0;
  26. if ((int)cur._Find_first() == i - l + 1 + 1 && i - l + 1 >= x) {
  27. ans.push_back(i - l + 1);
  28. }
  29. }
  30. if (ans.empty()) {
  31. cout << "-1 0\n";
  32. continue;
  33. }
  34. cout << ans[0] << ' ' << ans.size() << '\n';
  35. }
  36. }
Success #stdin #stdout 0.01s 5284KB
stdin
0
6 3
1 4 2 3 1 4
1 1
2 1
3 1
stdout
1 2
4 1
3 2