Skip to content

Commit

Permalink
Merge pull request #127 from BurningFalls/main
Browse files Browse the repository at this point in the history
week17_burningfalls
  • Loading branch information
BurningFalls authored Sep 9, 2024
2 parents 2b2128c + 6558d6d commit caf90bd
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
35 changes: 35 additions & 0 deletions week17/A_32160/burningfalls/32160.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <bits/stdc++.h>
using namespace std;

#define FASTIO cin.tie(0); ios_base::sync_with_stdio(0);

int main() {
FASTIO;
int N;
cin >> N;

if ((N / 2) % 2 == 0) {
cout << N;
} else {
cout << N - 1;
}
cout << "\n";

int num = N - 1;
for(int i = N - 2; i >= 1; i--) {
cout << i << " " << num << "\n";
num = abs(i - num);
}
cout << N << " " << num << "\n";

return 0;
}









43 changes: 43 additions & 0 deletions week17/B_31997/burningfalls/31997.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <bits/stdc++.h>
using namespace std;

#define FASTIO cin.tie(0); ios_base::sync_with_stdio(0);

int main() {
FASTIO;
int N, M, T;
cin >> N >> M >> T;
vector<pair<int, int>> v(N + 1);
for(int i = 1; i <= N; i++) {
cin >> v[i].first >> v[i].second;
}

vector<int> sum(T + 1, 0);
for(int i = 1; i <= M; i++) {
int c, d;
cin >> c >> d;
int left = max(v[c].first, v[d].first);
int right = min(v[c].second, v[d].second);
if (left >= right) continue;
sum[left]++;
sum[right]--;
}

for(int i = 1; i <= T; i++) {
sum[i] = sum[i - 1] + sum[i];
}

for(int i = 0; i < T; i++) {
cout << sum[i] << "\n";
}

return 0;
}








86 changes: 86 additions & 0 deletions week17/C_31932/burningfalls/31932.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <bits/stdc++.h>
using namespace std;

#define FASTIO cin.tie(0); ios_base::sync_with_stdio(0);
#define ll long long
#define LINF 1e18
#define MAX 100001

struct NODE1 {
ll n;
ll d;
ll t;
};

struct NODE2 {
ll n;
ll d;

bool operator<(const NODE2& node) const {
return d > node.d;
}
};

int N, M;
vector<vector<NODE1>> Edge(MAX, vector<NODE1>());
vector<ll> dist(MAX, LINF);
priority_queue<NODE2> pq;

void DT(ll snode, ll stime) {
dist[snode] = stime;
pq.push({snode, dist[snode]});
while(!pq.empty()) {
NODE2 cur = pq.top();
pq.pop();
if (cur.d > dist[cur.n]) continue;
for(int i = 0; i < Edge[cur.n].size(); i++) {
ll next = Edge[cur.n][i].n;
ll ndist = cur.d + Edge[cur.n][i].d;
if (ndist > Edge[cur.n][i].t) continue;
if (dist[next] > ndist) {
dist[next] = ndist;
pq.push({next, dist[next]});
}
}
}
}

int main() {
FASTIO;
cin >> N >> M;
for(int i = 1; i <= M; i++) {
ll u, v, d, t;
cin >> u >> v >> d >> t;
Edge[u].push_back({v, d, t});
Edge[v].push_back({u, d, t});
}

ll left = 0, right = LINF;
ll ans = -1;
while(left <= right) {
ll mid = (left + right) / 2;
for(int i = 1; i <= N; i++) {
dist[i] = LINF;
}
DT(1, mid);

if (dist[N] != LINF) {
ans = mid;
left = mid + 1;
} else if (dist[N] == LINF) {
right = mid - 1;
}
}
cout << ans << "\n";

return 0;
}









0 comments on commit caf90bd

Please sign in to comment.