QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586352 | #5073. Elden Ring | BlckCrw | WA | 65ms | 5788kb | C++20 | 1.8kb | 2024-09-24 11:05:56 | 2024-09-24 11:05:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define mp make_pair
#define vi vector<int>
#define eb emplace_back
#define pii pair<int, int>
#define fi first
#define se second
#define rep(rp,a,b) for(int rp=a;rp<=b;++rp)
#define per(bl,a,b) for(int bl=a;bl>=b;--bl)
#define segc int mid = L+R>>1, lc = now<<1, rc = lc|1
const int N = 2e5+5, MOD = 998244353, INF = 1e9;
inline void chkmin(int &x,int y) {x = y>x ? x : y;}
inline void chkmax(int &x,int y) {x = y>x ? y : x;}
inline int read() {
register int x = 0, f = 1;
register char ch = 0;
while(ch < 48 || ch > 57) {
ch = getchar();
if (ch == '-') f = -1;
}
while(ch >= 48 && ch <= 57) x = x*10+(ch^48), ch = getchar();
return f*x;
}
vi G[N];
int n, m, A, B, a[N], dis[N];
void sol1() {
queue<int> q;
q.push(1);
dis[1] = 0;
while (!q.empty()) {
int x = q.front(); q.pop();
if (x == n) return printf("%d\n", dis[n]), void();
for (int y:G[x]) if (!dis[y] && y != 1) {
if (1ll*a[1]+A*dis[x] > 1ll*a[y]+(dis[x]*B)) {
dis[y] = dis[x]+1;
q.push(y);
} else dis[y] = -1;
}
} puts("-1");
}
void sol2() {
priority_queue<pii> q;
q.push(mp(0, 1));
dis[1] = 0;
while (!q.empty()) {
int x = q.top().se; q.pop();
for (int y:G[x]) if (!dis[y] && y != 1) {
dis[y] = max(dis[x]+1, (a[y]-a[1]+A)/(A-B)+1);
q.push(mp(-dis[y], y));
}
}
sort(dis+1, dis+n);
rep (i, 1, dis[n]-1) if (i < dis[i+1]) return puts("-1"), void();
printf("%d\n", dis[n]);
}
void solve() {
n = read(), m = read(), A = read(), B = read();
rep (i, 1, n) dis[i] = 0, G[i].clear();
rep (i, 1, m) {
int u = read(), v = read();
G[u].eb(v), G[v].eb(u);
}
rep (i, 1, n) a[i] = read();
if (A <= B) sol1();
else sol2();
}
int main() {
int T = read(); while (T --) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5788kb
input:
2 5 4 5 8 1 2 1 3 1 4 4 5 15 1 1 1 1 5 4 10 5 1 2 1 3 1 4 4 5 10 4 4 4 19
output:
2 4
result:
ok 2 number(s): "2 4"
Test #2:
score: -100
Wrong Answer
time: 65ms
memory: 3808kb
input:
100000 6 10 107812 105568 6 5 3 6 4 6 4 2 5 1 5 6 4 5 1 3 1 2 2 5 124065 140875 29890 80077 116532 35394 9 10 82107 88302 1 2 2 3 5 3 5 1 1 4 9 6 3 5 8 2 5 6 7 5 22670 3735 33660 92823 139960 89319 83335 158330 117349 6 10 181257 173221 5 3 3 4 3 1 5 1 2 1 3 6 3 1 6 2 3 6 4 3 76902 46253 123092 2661...
output:
-1 -1 -1 1 -1 1 1 -1 -1 -1 1 1 2 4 -1 -1 -1 -1 -1 -1 -1 2 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 2 3 -1 2 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
wrong answer 6th numbers differ - expected: '-1', found: '1'