Skip to content

Commit e05ae9c

Browse files
committed
update
1 parent 2bf79b9 commit e05ae9c

File tree

942 files changed

+8587
-8693
lines changed

Some content is hidden

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

942 files changed

+8587
-8693
lines changed

.vscode/launch.json

-29
This file was deleted.

.vscode/settings.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"files.associations": {
3-
"iostream": "cpp",
4-
"random": "cpp",
5-
"array": "cpp",
63
"any": "cpp",
4+
"array": "cpp",
75
"atomic": "cpp",
86
"bit": "cpp",
97
"*.tcc": "cpp",
@@ -46,6 +44,7 @@
4644
"memory_resource": "cpp",
4745
"numeric": "cpp",
4846
"optional": "cpp",
47+
"random": "cpp",
4948
"ratio": "cpp",
5049
"regex": "cpp",
5150
"string": "cpp",
@@ -59,6 +58,7 @@
5958
"initializer_list": "cpp",
6059
"iomanip": "cpp",
6160
"iosfwd": "cpp",
61+
"iostream": "cpp",
6262
"istream": "cpp",
6363
"limits": "cpp",
6464
"mutex": "cpp",
@@ -74,6 +74,5 @@
7474
"typeinfo": "cpp",
7575
"valarray": "cpp",
7676
"variant": "cpp"
77-
},
78-
"C_Cpp.errorSquiggles": "Disabled"
77+
}
7978
}

.vscode/tasks.json

-26
This file was deleted.

Apartments/attic/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mainSolution": {
3-
"value": "/mnt/e/Compeitive Programming/CSES - CSES Problem Set/Apartments/main.cpp"
3+
"value": "/mnt/d/CP/CSES - CSES Problem Set/Apartments/main.cpp"
44
},
55
"bruteSolution": {},
66
"generator": {},

Apartments/attic/main.cpp.md5

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
219a799e37b81475e5b99072b60828d9
1+
74b054588b39f6ce03a5a5c046ea308a

Apartments/attic/sol

34.8 KB
Binary file not shown.

Apartments/main

-28.9 KB
Binary file not shown.

Apartments/main.cpp

+19-33
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,39 @@
11
#include <bits/stdc++.h>
2-
#include <ext/pb_ds/assoc_container.hpp>
3-
#include <ext/pb_ds/tree_policy.hpp>
42

53
using namespace std;
6-
using namespace __gnu_pbds;
74

8-
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
5+
#define ar array
6+
#define ll long long
97

10-
const int MAX_N = 1e5 + 5;
11-
const int MAX_L = 20; // ~ Log N
12-
const long long MOD = 1e9 + 7;
13-
const long long INF = 1e9 + 7;
14-
const double EPS = 1e-9;
8+
const int MAX_N = 1e5 + 1;
9+
const ll MOD = 1e9 + 7;
10+
const ll INF = 1e9;
1511

16-
typedef long long ll;
17-
typedef vector<int> vi;
18-
typedef pair<int,int> ii;
19-
typedef vector<ii> vii;
20-
typedef vector<vi> vvi;
2112

22-
#define LSOne(S) (S & (-S))
23-
#define isBitSet(S, i) ((S >> i) & 1)
2413

2514
void solve() {
2615
int n, m, k; cin >> n >> m >> k;
27-
int a[n], b[m];
28-
for (int i = 0; i < n; i++) cin >> a[i];
29-
for (int i = 0; i < m; i++) cin >> b[i];
30-
sort(a, a + n);
31-
sort(b, b + m);
32-
33-
int ans = 0, i = 0, j = 0;
34-
while (i < n && j < m) {
35-
if (b[j] < a[i] - k) j++;
36-
else if (b[j] > a[i] + k) i++;
37-
else i++, j++, ans++;
16+
vector<int> a(n), b(m);
17+
for (int &x : a) cin >> x;
18+
for (int &x : b) cin >> x;
19+
sort(a.begin(), a.end());
20+
sort(b.begin(), b.end());
21+
int ans = 0;
22+
for (int i = 0, j = 0; i < n && j < m;) {
23+
if (a[i] + k < b[j]) i++;
24+
else if(a[i] - k > b[j]) j++;
25+
else ans++, i++, j++;
3826
}
3927
cout << ans << "\n";
4028
}
4129

4230
int main() {
4331
ios_base::sync_with_stdio(0);
4432
cin.tie(0); cout.tie(0);
45-
//freopen("input.txt", "r", stdin);
46-
//freopen("output.txt", "w", stdout);
47-
48-
int tc; tc = 1;
33+
int tc = 1;
34+
// cin >> tc;
4935
for (int t = 1; t <= tc; t++) {
50-
//cout << "Case #" << t << ": ";
36+
// cout << "Case #" << t << ": ";
5137
solve();
5238
}
53-
}
39+
}

Apple Division/attic/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mainSolution": {
3-
"value": "/mnt/e/Compeitive Programming/CSES - CSES Problem Set/Apple Division/main.cpp"
3+
"value": "/mnt/d/CP/CSES - CSES Problem Set/Apple Division/main.cpp"
44
},
55
"bruteSolution": {},
66
"generator": {},

Apple Division/attic/main.cpp.md5

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f086919a5aefbd64f4a077c3bf459699
1+
b3a17e6413a41b1da94c736914e1ab02

Apple Division/attic/sol

21 KB
Binary file not shown.

Apple Division/main.cpp

+20-43
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,39 @@
11
#include <bits/stdc++.h>
2-
#include <ext/pb_ds/assoc_container.hpp>
3-
#include <ext/pb_ds/tree_policy.hpp>
42

53
using namespace std;
6-
using namespace __gnu_pbds;
74

8-
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
5+
#define ar array
6+
#define ll long long
97

10-
const int MAX_N = 1e5 + 5;
11-
const int MAX_L = 20; // ~ Log N
12-
const long long MOD = 1e9 + 7;
13-
const long long INF = 1e9 + 7;
14-
const double EPS = 1e-9;
8+
const int MAX_N = 1e5 + 1;
9+
const ll MOD = 1e9 + 7;
10+
const ll INF = 1e18;
1511

16-
typedef long long ll;
17-
typedef vector<int> vi;
18-
typedef pair<int,int> ii;
19-
typedef vector<ii> vii;
20-
typedef vector<vi> vvi;
2112

22-
#define LSOne(S) (S & (-S))
23-
#define isBitSet(S, i) ((S >> i) & 1)
24-
25-
// N is small, so backtracking is possible
26-
27-
int N;
28-
ll arr[20], ans, total;
29-
30-
void backtrack(int idx = 0, ll sum = 0) {
31-
if (idx == N) {
32-
ll diff = abs(total - 2 * sum);
33-
ans = min(ans , diff);
34-
return;
35-
}
36-
backtrack(idx + 1, sum);
37-
backtrack(idx + 1, sum + arr[idx]);
38-
}
3913

4014
void solve() {
41-
cin >> N;
42-
for (int i = 0; i < N; i++) {
43-
cin >> arr[i];
44-
total += arr[i];
15+
int n; cin >> n;
16+
vector<int> a(n);
17+
for (int &x : a) cin >> x;
18+
ll ans = INF;
19+
for (int mask = 0; mask < (1 << n); mask++) {
20+
ll sum1 = 0, sum2 = 0;
21+
for (int i = 0; i < n; i++) {
22+
if (mask >> i & 1) sum1 += a[i];
23+
else sum2 += a[i];
24+
}
25+
ans = min(ans, abs(sum1 - sum2));
4526
}
46-
ans = total;
47-
backtrack();
4827
cout << ans << "\n";
4928
}
5029

5130
int main() {
5231
ios_base::sync_with_stdio(0);
5332
cin.tie(0); cout.tie(0);
54-
//freopen("input.txt", "r", stdin);
55-
//freopen("output.txt", "w", stdout);
56-
57-
int tc; tc = 1;
33+
int tc = 1;
34+
// cin >> tc;
5835
for (int t = 1; t <= tc; t++) {
59-
//cout << "Case #" << t << ": ";
36+
// cout << "Case #" << t << ": ";
6037
solve();
6138
}
62-
}
39+
}

Array Description/attic/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mainSolution": {
3-
"value": "/mnt/e/Compeitive Programming/CSES - CSES Problem Set/Array Description/main.cpp"
3+
"value": "/mnt/d/CP/CSES - CSES Problem Set/Array Description/main.cpp"
44
},
55
"bruteSolution": {},
66
"generator": {},

Array Description/attic/main.cpp.md5

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4fb8f129deaf926040080bf81f937bc0
1+
4667b3e54b829e91b6447bd87a1fc056

Array Description/attic/sol

-42.3 KB
Binary file not shown.

Array Description/attic/stderr

-4
This file was deleted.

Array Description/main.cpp

+29-36
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,53 @@
11
#include <bits/stdc++.h>
2-
#include <ext/pb_ds/assoc_container.hpp>
3-
#include <ext/pb_ds/tree_policy.hpp>
42

53
using namespace std;
6-
using namespace __gnu_pbds;
74

8-
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
5+
#define ar array
6+
#define ll long long
97

10-
const int MAX_N = 1e5 + 5;
11-
const int MAX_L = 20; // ~ Log N
12-
const long long MOD = 1e9 + 7;
13-
const long long INF = 1e9 + 7;
14-
const double EPS = 1e-9;
15-
16-
typedef long long ll;
17-
typedef vector<int> vi;
18-
typedef pair<int,int> ii;
19-
typedef vector<ii> vii;
20-
typedef vector<vi> vvi;
21-
22-
#define LSOne(S) (S & (-S))
23-
#define isBitSet(S, i) ((S >> i) & 1)
8+
const int MAX_N = 1e5 + 1;
9+
const ll MOD = 1e9 + 7;
10+
const ll INF = 1e9;
2411

2512

2613

2714
void solve() {
2815
int n, m; cin >> n >> m;
29-
int x[n];
30-
for (int i = 0; i < n; i++) cin >> x[i];
31-
vvi dp(n, vi(m + 1, 0));
32-
for (int i = 1; i <= m; i++)
33-
dp[0][i] = (x[0] == 0 || x[0] == i);
16+
vector<int> a(n);
17+
for (int &x : a) cin >> x;
18+
int dp[n][m + 1];
19+
memset(dp, 0, sizeof dp);
20+
if (a[0] == 0) {
21+
for (int i = 1; i <= m; i++) dp[0][i] = 1;
22+
} else {
23+
dp[0][a[0]] = 1;
24+
}
3425
for (int i = 1; i < n; i++) {
35-
for (int j = 1; j <= m; j++) {
36-
if (x[i] == 0 || x[i] == j) {
37-
dp[i][j] = dp[i - 1][j];
38-
if (j > 1) (dp[i][j] += dp[i - 1][j - 1]) %= MOD;
39-
if (j < m) (dp[i][j] += dp[i - 1][j + 1]) %= MOD;
26+
if (a[i] == 0) {
27+
for (int j = 1; j <= m; j++) {
28+
dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
29+
if (j > 1) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
30+
if (j < m) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % MOD;
4031
}
32+
} else {
33+
int j = a[i];
34+
dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
35+
if (j > 1) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
36+
if (j < m) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % MOD;
4137
}
4238
}
4339
int ans = 0;
44-
for (int i = 1; i <= m; i++)
45-
(ans += dp[n - 1][i]) %= MOD;
40+
for (int i = 1; i <= m; i++) ans = (ans + dp[n - 1][i]) % MOD;
4641
cout << ans << "\n";
4742
}
4843

4944
int main() {
5045
ios_base::sync_with_stdio(0);
5146
cin.tie(0); cout.tie(0);
52-
//freopen("input.txt", "r", stdin);
53-
//freopen("output.txt", "w", stdout);
54-
55-
int tc; tc = 1;
47+
int tc = 1;
48+
// cin >> tc;
5649
for (int t = 1; t <= tc; t++) {
57-
//cout << "Case #" << t << ": ";
50+
// cout << "Case #" << t << ": ";
5851
solve();
5952
}
60-
}
53+
}

Array Division/attic/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mainSolution": {
3-
"value": "/mnt/e/Compeitive Programming/CSES - CSES Problem Set/Array Division/main.cpp"
3+
"value": "/mnt/d/CP/CSES - CSES Problem Set/Array Division/main.cpp"
44
},
55
"bruteSolution": {},
66
"generator": {},

0 commit comments

Comments
 (0)