Skip to content

Commit d6fb8ca

Browse files
committed
Solve problems 32B, 69A, 263A, 266B and 271A from codeforces
1 parent 510f564 commit d6fb8ca

File tree

6 files changed

+138
-0
lines changed

6 files changed

+138
-0
lines changed

CodeForces/263A. Beautiful Matrix.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <iostream>
2+
#include <cmath>
3+
4+
using namespace std;
5+
6+
int board[5][5];
7+
8+
int main() {
9+
int x, y;
10+
11+
for(int i = 0; i < 5; i++)
12+
for(int j = 0; j < 5; j++) {
13+
cin >> board[i][j];
14+
15+
if(board[i][j] == 1) {
16+
x = i;
17+
y = j;
18+
}
19+
}
20+
21+
cout << abs(2 - x) + abs(2 - y) << endl;
22+
23+
return 0;
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <memory.h>
4+
5+
using namespace std;
6+
7+
int main() {
8+
int n, t;
9+
string s;
10+
cin >> n >> t >> s;
11+
12+
while(t--)
13+
for(int i = n - 1; i >= 0; i--)
14+
if(s[i] == 'G' && i-1 >= 0 && s[i-1] == 'B') {
15+
s[i] = 'B';
16+
s[i-1] = 'G';
17+
i--;
18+
}
19+
20+
cout << s << endl;
21+
22+
return 0;
23+
}

CodeForces/271A. Beautiful Year.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
#include <memory.h>
3+
4+
using namespace std;
5+
6+
int freq[10], r;
7+
8+
bool distinct(int n) {
9+
memset(freq, 0, sizeof freq);
10+
r = 0;
11+
12+
while(n) {
13+
freq[n % 10]++;
14+
n /= 10;
15+
}
16+
17+
for(int i = 0; i < 10; i++)
18+
if(freq[i])
19+
r++;
20+
21+
if(r == 4)
22+
return true;
23+
24+
return false;
25+
}
26+
27+
int main() {
28+
int n;
29+
cin >> n;
30+
n++;
31+
32+
while(!distinct(n))
33+
n++;
34+
35+
cout << n << endl;
36+
37+
return 0;
38+
}

CodeForces/32B. Borze.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
using namespace std;
5+
6+
int main() {
7+
string s;
8+
cin >> s;
9+
10+
for(int i = 0; i < s.size(); i++)
11+
if(s[i] == '.') cout << '0';
12+
else if(i+1 < s.size() && s[i] == '-' && s[i+1] == '.') {
13+
cout << '1';
14+
i++;
15+
} else if(i+1 < s.size() && s[i] == '-' && s[i+1] == '-') {
16+
cout << '2';
17+
i++;
18+
}
19+
20+
cout << endl;
21+
return 0;
22+
}

CodeForces/69A. Young Physicist.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int n, a, b, c, r1, r2, r3;
7+
r1 = r2 = r3 = 0;
8+
9+
cin >> n;
10+
n--;
11+
12+
cin >> r1 >> r2 >> r3;
13+
14+
while(n--) {
15+
cin >> a >> b >> c;
16+
17+
r1 += a;
18+
r2 += b;
19+
r3 += c;
20+
}
21+
22+
if(!r1 && !r2 && !r3) cout << "YES" << endl;
23+
else cout << "NO" << endl;
24+
25+
return 0;
26+
}

CodeForces/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [25A. IQ test](http://codeforces.com/problemset/problem/25/A)
1111
- [25B. Phone numbers](http://codeforces.com/problemset/problem/25/B)
1212
- [26A. Almost Prime](http://codeforces.com/problemset/problem/26/A)
13+
- [32B. Borze](https://repl.it/languages/cpp11)
1314
- [35C. Fire Again](http://codeforces.com/contest/35/problem/C)
1415
- [35D. Animals](http://codeforces.com/contest/35/problem/D)
1516
- [41A. Translation](http://codeforces.com/problemset/problem/41/A)
@@ -18,6 +19,7 @@
1819
- [56D. Changing a String](http://codeforces.com/contest/56/problem/D)
1920
- [58A. Chat room](http://codeforces.com/problemset/problem/58/A)
2021
- [59A. Word](http://codeforces.com/problemset/problem/59/A)
22+
- [69A. Young Physicist](http://codeforces.com/problemset/problem/69/A)
2123
- [71A. Way Too Long Words](http://codeforces.com/problemset/problem/71/A)
2224
- [75A. Life Without Zeros](http://codeforces.com/contest/75/problem/A)
2325
- [96A. Football](http://codeforces.com/problemset/problem/96/A)
@@ -37,7 +39,10 @@
3739
- [231A. Team](http://codeforces.com/problemset/problem/231/A)
3840
- [236A. Boy or Girl](http://codeforces.com/problemset/problem/236/A)
3941
- [262A. Roma and Lucky Numbers](http://codeforces.com/problemset/problem/262/A)
42+
- [263A. Beautiful Matrix](http://codeforces.com/problemset/problem/263/A)
43+
- [266B. Queue at the School](http://codeforces.com/problemset/problem/266/B)
4044
- [268A. Games](http://codeforces.com/problemset/problem/268/A)
45+
- [271A. Beautiful Year](http://codeforces.com/problemset/problem/271/A)
4146
- [281A. Word Capitalization](http://codeforces.com/problemset/problem/281/A)
4247
- [282A. Bit++](http://codeforces.com/problemset/problem/282/A)
4348
- [304A. Pythagorean Theorem II](http://codeforces.com/problemset/problem/304/A)

0 commit comments

Comments
 (0)