QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#255768 | #6645. 百合 | hongrock | WA | 302ms | 39392kb | C++17 | 1.4kb | 2023-11-18 17:03:02 | 2023-11-18 17:03:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1 << 17;
const int M = 18;
const ll inf = (ll)1e18;
int K, m, s, n, a[M];
vector<pair<int,int>> V[N];
ll dist[N];
int lst[N][M];
struct Node{
int id;
ll d;
Node(){}
Node(int id, ll d):id(id),d(d){}
bool operator < (const Node &A)const{
return d > A.d;
}
};
priority_queue<Node> Q;
void dfs(int id, int x, int y, ll d){
if(d + a[y] < dist[id]){
dist[id] = d + a[y];
Q.emplace(id, dist[id]);
}
if(x + 1 < lst[id][y]){
dfs(id, x + 1, y, d);
dfs(id^(1<<x), x+1, y+1, d);
lst[id][y] = x;
}
}
int main(){
int x, y, z;
scanf("%d %d %d", &K, &m, &s);
for(int i=1; i<=K; ++i) scanf("%d", a+i);
n = 1 << K;
while(m--){
scanf("%d %d %d", &x, &y, &z);
V[x].emplace_back(y, z);
V[y].emplace_back(x, z);
}
for(int i=0; i<n; ++i){
dist[i] = inf;
for(int j=0; j<=K; ++j){
lst[i][j] = K + 1;
}
}
dist[s] = 0;
Q.emplace(s, 0);
while(!Q.empty()){
auto nd = Q.top(); Q.pop();
if(nd.d > dist[nd.id]) continue;
dfs(nd.id, 0, 0, nd.d);
for(auto [to, z] : V[nd.id]){
if(nd.d + z < dist[to]){
dist[to] = nd.d + z;
Q.emplace(to, dist[to]);
}
}
}
for(int i=0; i<n; ++i){
printf("%lld%c", dist[i], " \n"[i == n - 1]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 302ms
memory: 39392kb
input:
17 176734 32035 174241040 312806717 869838047 1051792036 618192507 729602782 144984364 904057367 922632751 676477964 651564213 314995751 370303789 14711019 7843270 941966995 532030000 50422 32035 12218 70235 32035 1913 84994 70235 27964 94874 84994 3469 32802 50422 6989 18176 32802 17541 91233 50422...
output:
104839 14747561 62870 66963 79027 7868957 77164 7858869 14736706 7868957 7888587 64039 51115 104082 70150 72482 57864 60745 69433 62907 88618 7858789 144984680 14726538 51092 68271 7855529 7881281 94531 87056 7878168 59789 80215 7868957 87126 74831 74335 62096 51671 68573 7924523 44764 14728409 7860...
result:
wrong answer 2nd numbers differ - expected: '7871804', found: '14747561'