-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ead838
commit 6558d6d
Showing
3 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|