Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0ff2527

Browse files
committed
Today ps
1 parent 2cca6d1 commit 0ff2527

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535

3636
cmake-build-debug/
3737
build/
38+
*.cph/

‎Baekjoon/Cpp/1041.cpp‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
using pll = pair<ll, ll>;
6+
7+
bool compare(pll a, pll b)
8+
{
9+
return min(a.first, a.second) < min(b.first, b.second);
10+
}
11+
12+
int main()
13+
{
14+
ios::sync_with_stdio(0);
15+
cin.tie(0);
16+
ll n, i, c, d1, d2, d3, sum = 0, mx = 0, dice[6];
17+
pll af, cd, be;
18+
cin >> n;
19+
for (i = 0; i < 6; i++)
20+
{
21+
cin >> dice[i];
22+
mx = max(dice[i], mx);
23+
sum += dice[i];
24+
}
25+
af = make_pair(dice[0], dice[5]);
26+
cd = make_pair(dice[2], dice[3]);
27+
be = make_pair(dice[1], dice[4]);
28+
pll arr[3] = {af, cd, be};
29+
sort(arr, arr + 3, compare);
30+
c = 0;
31+
if (n == 1)
32+
{
33+
cout << sum - mx;
34+
}
35+
else
36+
{
37+
d1 = min(arr[0].first, arr[0].second);
38+
d2 = min(arr[1].first, arr[1].second);
39+
d3 = min(arr[2].first, arr[2].second);
40+
c += (d1 + d2 + d3) * 4;
41+
c += (d1 + d2) * (4 + (n - 2) * 8);
42+
c += d1 * (n * n * 5 - 12 - (4 + (n - 2) * 8) * 2);
43+
cout << c;
44+
}
45+
return 0;
46+
}

‎Baekjoon/Cpp/11779.cpp‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <bits/stdc++.h>
2+
#define INF 9223372036854775807
3+
4+
using namespace std;
5+
using ll = long long;
6+
using pll = pair<ll, ll>;
7+
using plvl = pair<ll, vector<ll>>;
8+
9+
ll dis[1001], cost[1001][1001];
10+
bool vst[1001][1001];
11+
12+
struct compare
13+
{
14+
bool operator()(const plvl &a, const plvl &b) const
15+
{
16+
return a.first > b.first;
17+
}
18+
};
19+
20+
int main()
21+
{
22+
ios_base::sync_with_stdio(0);
23+
cin.tie(0);
24+
ll n, m, a, b, c, i, s, e;
25+
vector<ll> cv, gph[1001];
26+
plvl cr, res;
27+
priority_queue<plvl, vector<plvl>, compare> pq;
28+
cin >> n >> m;
29+
while (m--)
30+
{
31+
cin >> a >> b >> c;
32+
if (a == b)
33+
{
34+
continue;
35+
}
36+
else if (vst[a][b])
37+
{
38+
cost[a][b] = min(cost[a][b], c);
39+
}
40+
else
41+
{
42+
gph[a].push_back(b);
43+
vst[a][b] = true;
44+
cost[a][b] = c;
45+
}
46+
}
47+
cin >> s >> e;
48+
for (i = 1; i <= n; i++)
49+
{
50+
dis[i] = INF;
51+
}
52+
cv.push_back(s);
53+
dis[s] = 0;
54+
pq.push(make_pair(0, cv));
55+
while (pq.empty() == false)
56+
{
57+
cr = pq.top();
58+
cv = cr.second;
59+
pq.pop();
60+
c = cv.back();
61+
if (c == e)
62+
{
63+
res = cr;
64+
break;
65+
}
66+
for (auto i : gph[c])
67+
{
68+
if (cost[c][i] + cr.first < dis[i])
69+
{
70+
dis[i] = cost[c][i] + cr.first;
71+
cv.push_back(i);
72+
pq.push(make_pair(dis[i], cv));
73+
cv.pop_back();
74+
}
75+
}
76+
}
77+
cout << res.first << "\n";
78+
b = res.second.size();
79+
cout << b << "\n";
80+
for (i = 0; i < b; i++)
81+
{
82+
cout << res.second[i] << " ";
83+
}
84+
return 0;
85+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /