Skip to content

Commit 3070224

Browse files
08.09.2025 16:53
1 parent ede9755 commit 3070224

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

266B Queue at the School.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

344A Magnets.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

467A George and Accommodation.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

486A Calculating Function.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

0 commit comments

Comments
 (0)