File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < algorithm>
3
+ using namespace std ;
4
+ int main ()
5
+ {
6
+ string s;
7
+ int n, t;
8
+ cin >> n >> t;
9
+ cin >> s;
10
+ while (t)
11
+ {
12
+ string temp = s;
13
+ for (int i = 0 ; i < s.size () - 1 ; i++)
14
+ {
15
+ if (s[i] == ' B' && s[i + 1 ] == ' G' )
16
+ {
17
+ temp[i] = ' G' ;
18
+ temp[i + 1 ] = ' B' ;
19
+ }
20
+ }
21
+ s = temp;
22
+ t--;
23
+ }
24
+ cout << s << endl;
25
+
26
+ return 0 ;
27
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+ int main ()
4
+ {
5
+ int n;
6
+ string s;
7
+ cin >> n;
8
+ string arr[n];
9
+ for (int i = 0 ; i < n; i++)
10
+ {
11
+ cin >> s;
12
+ arr[i] = s;
13
+ }
14
+ if (n == 1 )
15
+ {
16
+ cout << 1 << endl;
17
+ }
18
+ else
19
+ {
20
+ int c = 1 ;
21
+ for (int i = 0 ; i < n - 1 ; i++)
22
+ {
23
+ if (arr[i] != arr[i + 1 ])
24
+ {
25
+ c++;
26
+ }
27
+ }
28
+ cout << c << endl;
29
+ }
30
+ return 0 ;
31
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+ int main ()
4
+ {
5
+ int n, p, q, c = 0 ;
6
+ cin >> n;
7
+ while (n--)
8
+ {
9
+ cin >> p >> q;
10
+ if (q - p >= 2 )
11
+ {
12
+ c++;
13
+ }
14
+ }
15
+ cout << c << endl;
16
+ return 0 ;
17
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+ int main ()
4
+ {
5
+ long long int n;
6
+ cin >> n;
7
+ if (n % 2 == 0 )
8
+ {
9
+ cout << n / 2 << endl;
10
+ }
11
+ else
12
+ {
13
+ cout << n / 2 - n << endl;
14
+ }
15
+ return 0 ;
16
+ }
You can’t perform that action at this time.
0 commit comments