File tree 2 files changed +18
-17
lines changed
CodeForce/Round #627 (Div. 3)
2 files changed +18
-17
lines changed Original file line number Diff line number Diff line change 1
1
#include < iostream>
2
2
#include < algorithm>
3
- #include < string >
3
+ #include < vector >
4
4
using namespace std ;
5
+ vector<int >v;
5
6
int main () {
6
7
ios::sync_with_stdio (0 ); cin.tie (0 ); cout.tie (0 );
7
8
int t; cin >> t;
8
9
while (t--) {
9
- string s = ' ' ;
10
- string a; cin >> a;
11
- a += ' R' ;
12
- char prev =' L'
13
- int dist = 0 ;
14
- int tmp = 0 ;
15
- for (int i = 0 ; i < s.length (); i++) {
16
- if (prev == ' L' ) {
17
- tmp += 1 ;
18
- dist = max (dist, tmp);
19
- }
20
- else if (prev == ' R' ) {
21
- dist = max (dist, tmp);
22
- tmp = 0 ;
10
+ int n; cin >> n;
11
+ bool flag = false ;
12
+ for (int i = 0 ; i < n; i++) {
13
+ int x; cin >> x; v.push_back (x);
14
+ }
15
+ for (int i = 0 ; i < v.size () - 2 ; i++) {
16
+ if (flag) break ;
17
+ for (int j = i + 2 ; j < v.size (); j++) {
18
+ if (v[i] == v[j]) {
19
+ flag = true ;
20
+ break ;
21
+ }
23
22
}
24
- prev = s[
25
23
}
24
+ if (flag) cout << " YES\n " ;
25
+ else cout << " NO\n " ;
26
+ v.clear ();
26
27
}
27
28
return 0 ;
28
29
}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ int main() {
16
16
pos = i;
17
17
}
18
18
}
19
- tmp = max (tmp, int (s.length ()- pos));
19
+ tmp = max (tmp, int (s.length () - pos));
20
20
cout << tmp << " \n " ;
21
21
}
22
22
return 0 ;
You can’t perform that action at this time.
0 commit comments