Skip to content

Commit 664c882

Browse files
committed
add usaco folder
1 parent a1759e1 commit 664c882

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main (int argc, char *argv[]) {
6+
int n, s;
7+
cin >> n >> s;
8+
9+
return 0;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <map>
4+
#include <algorithm>
5+
6+
using namespace std;
7+
using pii = std::pair<int,int>;
8+
9+
void solve() {
10+
int n;
11+
cin >> n;
12+
vector<int> v(n);
13+
map<int, int> good;
14+
bool has_good = false;
15+
16+
for (int i = 0; i < n; i++) {
17+
cin >> v[i];
18+
v[i]--;
19+
if ( ((i > 0) && (v[i] == v[i-1])) || ((i > 1) && (v[i] == v[i-2])) ) {
20+
good[v[i]] = 1;
21+
has_good = true;
22+
}
23+
}
24+
//for(auto e: v) cout << e << " ";
25+
//cout << endl;
26+
27+
for(int i = 0; i < n; i++) {
28+
if (good[i] == 1) cout << (i + 1) << " ";
29+
}
30+
31+
if (!has_good) cout << -1;
32+
cout << '\n';
33+
}
34+
35+
int main (int argc, char *argv[]) {
36+
int T;
37+
cin >> T;
38+
while (T--) {
39+
solve();
40+
}
41+
return 0;
42+
}

0 commit comments

Comments
 (0)