Skip to content

Commit ca280a2

Browse files
Major Update
1 parent 92c4fc5 commit ca280a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+5459
-70
lines changed

A_Anti_Light_s_Cell_Guessing.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include <bits/stdc++.h>
2+
3+
#define ll long long
4+
#define ld long int
5+
#define vi vector<int>
6+
#define pii pair<int, int>
7+
#define pb push_back
8+
9+
using namespace std;
10+
11+
// 8""""8
12+
// 8 " eeeee eeeee eeee
13+
// 8e 8 88 8 8 8
14+
// 88 8 8 8e 8 8eee
15+
// 88 e 8 8 88 8 88
16+
// 88eee8 8eee8 88ee8 88ee
17+
18+
// --------MATHS OPERATIONS---------
19+
20+
const int N = 2e5 + 1;
21+
const int MOD = 1e9 + 7;
22+
ll fact[N], inv[N], invfact[N];
23+
void factInverse()
24+
{
25+
fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
26+
for (long long i = 2; i < N; i++)
27+
{
28+
fact[i] = (fact[i - 1] * i) % MOD;
29+
inv[i] = MOD - (inv[MOD % i] * (MOD / i) % MOD);
30+
invfact[i] = (inv[i] * invfact[i - 1]) % MOD;
31+
}
32+
}
33+
34+
int add(int a, int b)
35+
{
36+
if ((a += b) >= MOD)
37+
a -= MOD;
38+
else if (a < 0)
39+
a += MOD;
40+
return a;
41+
}
42+
43+
ll mul(int x, int y)
44+
{
45+
return (1LL * x * y) % MOD;
46+
}
47+
48+
ll nCr(int n, int r)
49+
{
50+
if (r > n)
51+
return 0;
52+
return mul(mul(fact[n], invfact[r]), invfact[n - r]);
53+
}
54+
55+
long long pow(long long base, long long n, long long m = MOD)
56+
{
57+
58+
long long ans = 1ll;
59+
while (n != 0)
60+
{
61+
if (n % 2)
62+
{
63+
ans = (ans * base) % m;
64+
n--;
65+
}
66+
else
67+
{
68+
base = (base * base) % m;
69+
n /= 2;
70+
}
71+
}
72+
return ans;
73+
}
74+
75+
// --------SOLVE---------
76+
77+
void solve()
78+
{
79+
ld n, m;
80+
cin >> n >> m;
81+
if (n == 1 and m == 1)
82+
{
83+
cout << 0;
84+
}
85+
else if (n == 1 or m == 1)
86+
{
87+
cout << 1;
88+
}
89+
else
90+
{
91+
cout << 2;
92+
}
93+
cout << endl;
94+
}
95+
96+
// --------XXXXXXXXX---------
97+
98+
int main()
99+
{
100+
ios_base::sync_with_stdio(0);
101+
cin.tie(0);
102+
103+
int t = 1;
104+
cin >> t;
105+
while (t--)
106+
{
107+
solve();
108+
}
109+
110+
return 0;
111+
}

A_Distance.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include <bits/stdc++.h>
2+
3+
#define ll long long
4+
#define ld long int
5+
#define vi vector<int>
6+
#define pii pair<int, int>
7+
#define pb push_back
8+
9+
using namespace std;
10+
11+
// 8""""8
12+
// 8 " eeeee eeeee eeee
13+
// 8e 8 88 8 8 8
14+
// 88 8 8 8e 8 8eee
15+
// 88 e 8 8 88 8 88
16+
// 88eee8 8eee8 88ee8 88ee
17+
18+
// --------MATHS OPERATIONS---------
19+
20+
const int N = 2e5 + 1;
21+
const int MOD = 1e9 + 7;
22+
ll fact[N], inv[N], invfact[N];
23+
void factInverse()
24+
{
25+
fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
26+
for (long long i = 2; i < N; i++)
27+
{
28+
fact[i] = (fact[i - 1] * i) % MOD;
29+
inv[i] = MOD - (inv[MOD % i] * (MOD / i) % MOD);
30+
invfact[i] = (inv[i] * invfact[i - 1]) % MOD;
31+
}
32+
}
33+
34+
int add(int a, int b)
35+
{
36+
if ((a += b) >= MOD)
37+
a -= MOD;
38+
else if (a < 0)
39+
a += MOD;
40+
return a;
41+
}
42+
43+
ll mul(int x, int y)
44+
{
45+
return (1LL * x * y) % MOD;
46+
}
47+
48+
ll nCr(int n, int r)
49+
{
50+
if (r > n)
51+
return 0;
52+
return mul(mul(fact[n], invfact[r]), invfact[n - r]);
53+
}
54+
55+
long long pow(long long base, long long n, long long m = MOD)
56+
{
57+
58+
long long ans = 1ll;
59+
while (n != 0)
60+
{
61+
if (n % 2)
62+
{
63+
ans = (ans * base) % m;
64+
n--;
65+
}
66+
else
67+
{
68+
base = (base * base) % m;
69+
n /= 2;
70+
}
71+
}
72+
return ans;
73+
}
74+
75+
// --------SOLVE---------
76+
77+
void solve()
78+
{
79+
int x, y;
80+
cin >> x >> y;
81+
int sum = x + y;
82+
if (sum & 1)
83+
{
84+
cout << "-1 -1" << endl;
85+
}
86+
else
87+
{
88+
int to_reduce = sum /= 2;
89+
int sub_x = min(x, to_reduce);
90+
to_reduce -= sub_x;
91+
int sub_y = min(y, to_reduce);
92+
cout << x - sub_x << " " << y - sub_y << endl;
93+
}
94+
}
95+
96+
// --------XXXXXXXXX---------
97+
98+
int main()
99+
{
100+
ios_base::sync_with_stdio(0);
101+
cin.tie(0);
102+
103+
int t = 1;
104+
cin >> t;
105+
while (t--)
106+
{
107+
solve();
108+
}
109+
110+
return 0;
111+
}

A_Prefix_Sum_Primes.cpp

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include <bits/stdc++.h>
2+
3+
#define ll long long
4+
#define ld long int
5+
#define vi vector<int>
6+
#define pii pair<int, int>
7+
#define pb push_back
8+
9+
using namespace std;
10+
11+
// 8""""8
12+
// 8 " eeeee eeeee eeee
13+
// 8e 8 88 8 8 8
14+
// 88 8 8 8e 8 8eee
15+
// 88 e 8 8 88 8 88
16+
// 88eee8 8eee8 88ee8 88ee
17+
18+
// --------MATHS OPERATIONS---------
19+
20+
const int N = 2e5 + 1;
21+
const int MOD = 1e9 + 7;
22+
ll fact[N], inv[N], invfact[N];
23+
void factInverse()
24+
{
25+
fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
26+
for (long long i = 2; i < N; i++)
27+
{
28+
fact[i] = (fact[i - 1] * i) % MOD;
29+
inv[i] = MOD - (inv[MOD % i] * (MOD / i) % MOD);
30+
invfact[i] = (inv[i] * invfact[i - 1]) % MOD;
31+
}
32+
}
33+
34+
int add(int a, int b)
35+
{
36+
if ((a += b) >= MOD)
37+
a -= MOD;
38+
else if (a < 0)
39+
a += MOD;
40+
return a;
41+
}
42+
43+
ll mul(int x, int y)
44+
{
45+
return (1LL * x * y) % MOD;
46+
}
47+
48+
ll nCr(int n, int r)
49+
{
50+
if (r > n)
51+
return 0;
52+
return mul(mul(fact[n], invfact[r]), invfact[n - r]);
53+
}
54+
55+
long long pow(long long base, long long n, long long m = MOD)
56+
{
57+
58+
long long ans = 1ll;
59+
while (n != 0)
60+
{
61+
if (n % 2)
62+
{
63+
ans = (ans * base) % m;
64+
n--;
65+
}
66+
else
67+
{
68+
base = (base * base) % m;
69+
n /= 2;
70+
}
71+
}
72+
return ans;
73+
}
74+
75+
// --------SOLVE---------
76+
77+
void solve()
78+
{
79+
int n;
80+
cin >> n;
81+
int o_cnt = 0, t_cnt = 0;
82+
int temp;
83+
for (int i = 0; i < n; i++)
84+
{
85+
cin >> temp;
86+
if (temp == 1)
87+
{
88+
o_cnt++;
89+
}
90+
else
91+
{
92+
t_cnt++;
93+
}
94+
}
95+
if (o_cnt >= 1 and t_cnt >= 1)
96+
{
97+
cout << 2 << " " << 1 << " ";
98+
o_cnt--;
99+
t_cnt--;
100+
}
101+
102+
while (t_cnt)
103+
{
104+
cout << 2 << " ";
105+
t_cnt--;
106+
}
107+
108+
while (o_cnt)
109+
{
110+
cout << 1 << " ";
111+
o_cnt--;
112+
}
113+
}
114+
115+
// --------XXXXXXXXX---------
116+
117+
int main()
118+
{
119+
ios_base::sync_with_stdio(0);
120+
cin.tie(0);
121+
122+
int t = 1;
123+
// cin >> t;
124+
while (t--)
125+
{
126+
solve();
127+
}
128+
129+
return 0;
130+
}

0 commit comments

Comments
 (0)