Skip to content

Commit 96e9ae5

Browse files
authored
Merge pull request #7 from Modernbeast02/main
#Solutions To Rising Coder Challenge
2 parents cd5db81 + dc1b243 commit 96e9ae5

12 files changed

+163
-110
lines changed
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
#include <bits/stdc++.h>
22
using namespace std;
3+
#define ll long long int
4+
#define endl '\n'
35

4-
int* a;
5-
6+
void solve()
7+
{
8+
ll a, b, c;
9+
cin >> a >> b >> c;
10+
ll rem = (a + b + c) % 2;
11+
if (rem)
12+
{
13+
cout << "ODD\n";
14+
return;
15+
}
16+
cout << "EVEN\n";
17+
}
618
int main()
719
{
8-
int n;
9-
cin >> n;
10-
11-
a = new int[n];
12-
13-
for (int i = 0; i < 10; i++)
14-
a[i] = i + 1;
15-
for (int i = 0; i < 10; i++)
16-
cout << a[i] << " \n";
20+
ios_base::sync_with_stdio(false);
21+
cin.tie(NULL);
22+
int t = 1;
23+
// cin >> t;
24+
while (t--)
25+
solve();
26+
return 0;
1727
}

RisingCodersChallenge_v1/A_ParityOfSum.py

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
#define endl '\n'
5+
6+
void solve()
7+
{
8+
set<string> s;
9+
s.insert("ACM");
10+
s.insert("AMC");
11+
s.insert("CAM");
12+
s.insert("CMA");
13+
s.insert("MCA");
14+
s.insert("MAC");
15+
string st;
16+
cin >> st;
17+
if (s.find(st) != s.end())
18+
{
19+
cout << "ACM\n";
20+
return;
21+
}
22+
cout << "NOPE\n";
23+
}
24+
int main()
25+
{
26+
ios_base::sync_with_stdio(false);
27+
cin.tie(NULL);
28+
int t = 1;
29+
cin >> t;
30+
while (t--)
31+
solve();
32+
return 0;
33+
}

RisingCodersChallenge_v1/B_IsItACM.py

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
#include <bits/stdc++.h>
2-
32
using namespace std;
3+
#define ll long long int
4+
#define endl '\n'
45

56
void solve()
67
{
7-
int n, m;
8+
ll n, m;
89
cin >> n >> m;
9-
10-
vector<int> alice(m), bob(m);
10+
vector<ll> alice(m), bob(m);
1111
for (int i = 0; i < m; i++)
12+
{
1213
cin >> alice[i];
14+
}
1315
for (int i = 0; i < m; i++)
16+
{
1417
cin >> bob[i];
15-
16-
int score = 0;
17-
for (int i = 0; i < m; i++)
18-
score += alice[i] - bob[i];
19-
20-
if (score + n - m > 0)
18+
}
19+
ll aliceSum = accumulate(alice.begin(), alice.end(), 0LL);
20+
ll bobSum = accumulate(bob.begin(), bob.end(), 0LL);
21+
if (aliceSum + n - m > bobSum)
22+
{
2123
cout << "YES\n";
22-
else
23-
cout << "NO\n";
24-
}
25-
24+
return;
25+
}
26+
cout << "NO\n";
27+
}
2628
int main()
2729
{
28-
int t;
30+
ios_base::sync_with_stdio(false);
31+
cin.tie(NULL);
32+
int t = 1;
2933
cin >> t;
30-
31-
for (int i = 0; i < t; i++)
34+
while (t--)
3235
solve();
36+
return 0;
3337
}

RisingCodersChallenge_v1/C_FootballFantasy.py

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
#define endl '\n'
5+
6+
void solve()
7+
{
8+
string s, y;
9+
cin >> s >> y;
10+
ll k;
11+
cin >> k;
12+
map<char, char> mpp;
13+
for (int i = 0; i < k; i++)
14+
{
15+
char a, b;
16+
cin >> a >> b;
17+
mpp[a] = b;
18+
mpp[b] = a;
19+
}
20+
ll n = s.size();
21+
for (int i = 0; i < n; i++)
22+
{
23+
if (s[i] == y[i])
24+
{
25+
continue;
26+
}
27+
if (mpp[s[i]] == y[i])
28+
{
29+
continue;
30+
}
31+
cout << "NO\n";
32+
return;
33+
}
34+
cout << "YES\n";
35+
}
36+
int main()
37+
{
38+
ios_base::sync_with_stdio(false);
39+
cin.tie(NULL);
40+
int t = 1;
41+
cin >> t;
42+
while (t--)
43+
solve();
44+
return 0;
45+
}

RisingCodersChallenge_v1/D_AlienDictionary.py

Whitespace-only changes.
Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
#include <bits/stdc++.h>
22
using namespace std;
3+
#define ll long long int
4+
#define endl '\n'
35

4-
int main()
6+
void solve()
57
{
6-
int n;
8+
ll n;
79
cin >> n;
8-
9-
std::vector<std::vector<int>> phones(n);
10+
vector<pair<ll, ll>> v(n);
1011
for (int i = 0; i < n; i++)
1112
{
12-
int price, value;
13-
cin >> price >> value;
14-
phones[i] = {price, value};
13+
cin >> v[i].first >> v[i].second;
1514
}
16-
17-
sort(phones.begin(), phones.end());
18-
for (int i = 0; i < n - 1; i++)
15+
sort(v.begin(), v.end());
16+
ll mini = v[0].second;
17+
for (int i = 1; i < n; i++)
1918
{
20-
// (i, i + 1) compare ho raha hai
21-
// i = n - 1 hua toh i + 1 = n ho jaayega
22-
// index out of bound
23-
if (phones[i][0] < phones[i + 1][0]
24-
and phones[i][1] > phones[i + 1][1])
19+
if (v[i].second < mini)
2520
{
26-
cout << "NEW PHONE";
27-
return 0;
21+
cout << "NEW PHONE\n";
22+
return;
2823
}
24+
mini = max(mini, v[i].second);
2925
}
30-
31-
cout << "OLD IT IS";
26+
cout << "OLD IT IS\n";
27+
}
28+
int main()
29+
{
30+
ios_base::sync_with_stdio(false);
31+
cin.tie(NULL);
32+
int t = 1;
33+
// cin >> t;
34+
while (t--)
35+
solve();
36+
return 0;
3237
}

RisingCodersChallenge_v1/E_SuperiorInferiorPair.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)