ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211287 | #2401. 移动 | 18112606231 | 0 | 0ms | 0kb | C++11 | 3.0kb | 2024-08-10 12:11:58 | 2024-08-10 12:41:34 |
answer
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m, c, k, a, t, u, v, w, cz, l, r, mubiao[5][101], dis[101][101], head[100001], pos;
struct edge
{
int u, v, w, next;
} e[1000001];
void add(int u, int v, int w)
{
e[++pos].u = u;
e[pos].v = v;
e[pos].w = w;
e[pos].next = head[u];
head[u] = pos;
}
int dijstra(int st, int ed)
{
// cout<<st<<' '<<ed<<endl;
for (int i = 1; i <= n; i++)
dis[st][i] = 1e18;
dis[st][st] = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
q.push(make_pair(0, st));
while (!q.empty())
{
int u = q.top().second;
q.pop();
for (int i = head[u]; i; i = e[i].next)
{
int v = e[i].v;
if (dis[st][v] > dis[st][u] + e[i].w)
{
dis[st][v] = dis[st][u] + e[i].w;
q.push(make_pair(dis[st][v], v));
}
}
}
return dis[st][ed];
}
int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
signed main()
{
n = read();
m = read();
c = read();
k = read();
a = read();
t = read();
for (int i = 1; i <= n; i++)
{
u = read();
v = read();
w = read();
add(u, v, w);
add(v, u, w);
}
for (int i = 1; i <= c; i++)
{
for (int j = 1; j <= k; j++)
{
mubiao[j][i] = read();
}
}
while (t--)
{
cz = read();
if (cz == 1)
{
u = read();
for (int i = 1; i <= k; i++)
{
mubiao[i][u] = read();
}
}
else
{
l = read();
r = read();
int duiyin[5];
int minn = 1e18, ans, res = 0;
for (int j = l; j < r; j++)
{
for (int i = 1; i <= k; i++)
{
duiyin[i] = mubiao[i][j+1];
}
do
{
// cout<<"gernshin";
ans = 0;
int minnn = 1e18;
for (int i = 1; i <= k; i++)
{
ans += dijstra(mubiao[i][j], duiyin[i]);
minnn = min(minnn, dijstra(mubiao[i][j], duiyin[i]));
}
ans += minnn * (a - 1);
minn = min(minn, ans);
} while (next_permutation(duiyin + 1, duiyin + k + 1));
res+=minn;
}
printf("%lld\n", res);
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
100 4950 100 3 8 100 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 100000 1 ...
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #10:
score: 0
Runtime Error
input:
100 4950 351493 3 10 100000 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 10...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #19:
score: 0
Runtime Error
input:
100 4950 351493 1 10 100000 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 10...
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #28:
score: 0
Runtime Error
input:
100 4950 351493 1 10 100000 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 10...
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #46:
score: 0
Runtime Error
input:
100 4950 351493 3 10 100000 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 10...
output:
result:
Subtask #6:
score: 0
Runtime Error
Test #64:
score: 0
Runtime Error
input:
100 4950 100 3 8 100 1 2 100000 1 3 100000 1 4 100000 1 5 100000 1 6 100000 1 7 100000 1 8 100000 1 ...