Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- #define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
- #define fore(i, l, r) for (int i = int(l); i < int(r); i++)
- #define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
- #define all(a) (a).begin(), (a).end()
- #define sz(a) int((a).size())
- #define pb(a) push_back(a)
- #define mp(x, y) make_pair((x), (y))
- #define x first
- #define y second
- using namespace std;
- typedef long long li;
- typedef long double ld;
- typedef pair<int, int> pt;
- template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
- template<typename X> inline X sqr(const X& a) { return a * a; }
- const int INF = int(1e9);
- const li INF64 = li(1e18);
- const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;
- const int N = 300300;
- int n, a[N];
- inline bool read() {
- if (!(cin >> n)) return false;
- forn(i, n) assert(scanf("%d", &a[i]) == 1);
- return true;
- }
- inline void solve() {
- vector<pt> ans;
- for (int i = 0, j = 0; i < n; i = j) {
- set<int> used;
- while (j < n && !used.count(a[j])) {
- used.insert(a[j++]);
- }
- if (j == n) break;
- ans.pb(mp(i, j));
- j++;
- }
- if (ans.empty()) {
- puts("-1");
- return;
- }
- ans.back().y = max(ans.back().y, n - 1);
- cout << sz(ans) << endl;
- forn(i, sz(ans)) printf("%d %d\n", ans[i].x + 1, ans[i].y + 1);
- }
- int main() {
- #ifdef SU1
- assert(freopen("input.txt", "rt", stdin));
- //assert(freopen("output.txt", "wt", stdout));
- #endif
- cout << setprecision(10) << fixed;
- cerr << setprecision(5) << fixed;
- while (read()) {
- solve();
- //break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement