You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
760 B
35 lines
760 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
const int N = 110;
|
|
int a[N];
|
|
int st[10];
|
|
struct Node {
|
|
int st, ed;
|
|
};
|
|
vector<Node> q;
|
|
/*
|
|
5
|
|
1 2 3 3 2
|
|
*/
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) cin >> a[i]; // 密码数组
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
if (!st[a[i]]) {
|
|
st[a[i]] = 1;
|
|
for (int j = n; j; j--)
|
|
if (a[i] == a[j]) {
|
|
q.push_back({i, j});
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
// 从左到右枚举,所以,不再需再进行按左端点排序,现在就是按左端点排序完的
|
|
|
|
for (int i = 0; i < q.size(); i++) cout << q[i].st << " " << q[i].ed << endl;
|
|
|
|
return 0;
|
|
} |