Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrustyPwo committed Mar 21, 2024
1 parent 07b02a2 commit 8e845ea
Show file tree
Hide file tree
Showing 64 changed files with 809 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CodeBreaker/findingpavement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n, m; cin >> n >> m;
int ans1 = 0, ans2 = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
string s; cin >> s;
if (s == "pavement") ans1 = i, ans2 = j;
}
}
cout << ans1 << ' ' << ans2;
}
43 changes: 43 additions & 0 deletions CodeBreaker/lboard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, m, g[1005][1005];
int vpre[1005][1005], hpre[1005][1005];

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> g[i][j];
for (int i = 1; i <= n; i++) {
int cur = 0;
for (int j = 1; j <= m; j++) {
cur += a[i][j];
if (cur < 0) cur = 0;
vpre[i][j] = cur;'
}
for (int j = m; j >= 1; j--) {
vpre[i][j].first.second = vpre[i][j + 1].first.second + g[i][j];
vpre[i][j].second.second = max(vpre[i][j + 1].second.second, vpre[i][j].first.second);
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
hpre[i][j].first.first = hpre[i - 1][j].first.first + g[i][j];
hpre[i][j].second.first = max(hpre[i - 1][j].second.first, hpre[i][j].first.first);
}
for (int i = n; i >= 1; i--) {
hpre[i][j].first.second = hpre[i + 1][j].first.second + g[i][j];
hpre[i][j].second.second = max(hpre[i + 1][j].second.second, hpre[i][j].first.second);
}
}
int ans = 0;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
int vmx = max(vpre[i][j].second.first, vpre[i][j].second.second);
int hmx = max(hpre[i][j].second.first, hpre[i][j].second.second);
ans = max(ans, vmx + hmx - g[i][j]);
}
cout << ans;
}
8 changes: 8 additions & 0 deletions CodeBreaker/photo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

}
32 changes: 32 additions & 0 deletions CodeBreaker/strikes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, m, deg[500005];
vector<int> g[500005];

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 1; i < n; i++) {
int a, b; cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
deg[a]++, deg[b]++;
}

cin >> m; int ans = 1;
while (m--) {
int x; cin >> x;
if (x > 0) {
ans += deg[x] - 1;
deg[x]--;
for (const int u : g[x]) deg[u]--;
} else {
ans -= g[x].size() + 1;
deg[x] = g[x].size();
for (const int u : g[x]) deg[u]++;
}
cout << ans << '\n';
}
}
6 changes: 6 additions & 0 deletions CodeForces/1277/A/ans1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
10
1
9
45
12
81
Empty file added CodeForces/1277/A/err
Empty file.
7 changes: 7 additions & 0 deletions CodeForces/1277/A/in1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
6
18
1
9
100500
33
1000000000
33 changes: 33 additions & 0 deletions CodeForces/1277/A/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
#define int long long

int pre[15];

void test_case(int test) {
int n; cin >> n;
int digits = 0;

int tmp = n;
while (tmp) {
tmp /= 10;
digits++;
}

int ans = (digits - 1) * 9;

for (int i = 1; i <= 9; i++) {
if (n >= pre[digits] * i) ans++;
}

cout << ans << '\n';
}

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
pre[1] = 1;
for (int i = 2; i < 14; i++) pre[i] = pre[i - 1] * 10 + 1;
int t; cin >> t;
for (int i = 1; i <= t; i++) test_case(i);
return 0;
}
6 changes: 6 additions & 0 deletions CodeForces/1277/A/out1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
10
1
9
45
12
81
2 changes: 2 additions & 0 deletions CodeForces/1277/A/params
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main:main.cpp
url:https://codeforces.com/contest/1277/problem/A
10 changes: 10 additions & 0 deletions CodeForces/1927/F/ans1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 3
1 2 3
3 3
6 4 5
1 5
4 2 1 6 3
1 4
1 4 3 2
3 3
2 3 1
10 changes: 10 additions & 0 deletions CodeForces/1927/F/ans2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 3
1 2 3
3 3
6 4 5
1 5
4 2 1 6 3
1 4
1 4 3 2
3 3
2 3 1
Empty file added CodeForces/1927/F/err
Empty file.
44 changes: 44 additions & 0 deletions CodeForces/1927/F/in1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
5
6 6
1 2 1
2 3 1
3 1 1
4 5 1
5 6 1
6 4 1
6 6
1 2 10
2 3 8
3 1 5
4 5 100
5 6 40
6 4 3
6 15
1 2 4
5 2 8
6 1 7
6 3 10
6 5 1
3 2 8
4 3 4
5 3 6
2 6 6
5 4 5
4 1 3
6 4 5
4 2 1
3 1 7
1 5 5
4 6
2 3 2
1 3 10
1 4 1
3 4 7
2 4 5
1 2 2
4 5
2 1 10
3 1 3
4 2 6
1 4 7
2 3 3
44 changes: 44 additions & 0 deletions CodeForces/1927/F/in2
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
5
6 6
1 2 1
2 3 1
3 1 1
4 5 1
5 6 1
6 4 1
6 6
1 2 10
2 3 8
3 1 5
4 5 100
5 6 40
6 4 3
6 15
1 2 4
5 2 8
6 1 7
6 3 10
6 5 1
3 2 8
4 3 4
5 3 6
2 6 6
5 4 5
4 1 3
6 4 5
4 2 1
3 1 7
1 5 5
4 6
2 3 2
1 3 10
1 4 1
3 4 7
2 4 5
1 2 2
4 5
2 1 10
3 1 3
4 2 6
1 4 7
2 3 3
70 changes: 70 additions & 0 deletions CodeForces/1927/F/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, m, dsu[200005], sz[200005], p[200005];
vector<int> g[200005];
vector<pair<int, pair<int, int>>> edges;

int find(int v) {
if (dsu[v] == v) return v;
return dsu[v] = find(dsu[v]);
}

bool merge(int u, int v) {
u = find(u), v = find(v);
if (u == v) return false;
if (sz[u] < sz[v]) swap(u, v);
dsu[v] = u;
sz[u] += sz[v];
return true;
}

void dfs(int v, int par) {
for (const auto u : g[v]) {
if (u == par) continue;
p[u] = v;
dfs(u, v);
}
}

void test_case(int test) {
cin >> n >> m; edges.clear();
for (int i = 1; i <= n; i++) dsu[i] = i, sz[i] = 1, g[i].clear();
for (int i = 0; i < m; i++) {
int u, v, c; cin >> u >> v >> c;
edges.push_back({c, {u, v}});
}

sort(edges.begin(), edges.end(), greater<pair<int, pair<int, int>>>());

pair<int, int> last; int least;
for (const auto it : edges) {
int u = it.second.first, v = it.second.second;
if (merge(u, v)) {
g[u].push_back(v);
g[v].push_back(u);
} else {
last = it.second;
least = it.first;
}
}

p[last.first] = -1;
dfs(last.first, last.first);
vector<int> ans;
for (int node = last.second; node != -1; node = p[node]) {
ans.push_back(node);
}

cout << least << ' ' << ans.size() << '\n';
for (const auto it : ans) cout << it << ' ';
cout << '\n';
}

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int t; cin >> t;
for (int i = 1; i <= t; i++) test_case(i);
return 0;
}
10 changes: 10 additions & 0 deletions CodeForces/1927/F/out1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 3
2 3 1
3 3
4 5 6
1 4
2 3 6 4
1 3
4 3 1
3 3
3 1 2
10 changes: 10 additions & 0 deletions CodeForces/1927/F/out2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 3
2 3 1
3 3
4 5 6
1 4
2 3 6 4
1 3
4 3 1
3 3
3 1 2
2 changes: 2 additions & 0 deletions CodeForces/1927/F/params
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
url:https://codeforces.com/contest/1927/problem/F
main:main.cpp
13 changes: 13 additions & 0 deletions CodeForces/1927/G/ans1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1
2
1
1
1
3
1
2
3
4
2
3
3
Loading

0 comments on commit 8e845ea

Please sign in to comment.