QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#497978 | #5073. Elden Ring | PorNPtree | Compile Error | / | / | C++17 | 2.6kb | 2024-07-29 21:14:01 | 2024-07-29 21:14:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N];
int a[N], d[N], vis[N];
signed main() {
int T; scanf("%d", &T);
for (int te = 1; te <= n; ++te) {
int n, m, A, B; scanf("%d%d%d%d", &n, &m, &A, &B);
for (int i = 1; i <= n; ++i) G[i].clear();
for (int i = 1, x, y; i <= m; ++i) {
scanf("%d%d", &x, &y);
if (te == 525) printf("%d %d\n", x, y);
G[x].push_back(y), G[y].push_back(x);
}
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), ((i > 1) && (a[i] += B));
A -= B;
if (te == 525) {
printf("%d %d %d %d\n", n, m, A + B, B);
for (int i = 1; i <= n; ++i) printf("%d%c", a[i], " \n"[i == n]);
}
if (A <= 0) {
for (int i = 1; i <= n; ++i) d[i] = 1e9;
d[1] = 0;
queue<int> Q; Q.push(1);
while (!Q.empty()) {
int x = Q.front();
Q.pop();
for (auto v : G[x]) {
if (d[x] + 1 < d[v] && a[1] + d[x] * A > a[v]) {
d[v] = d[x] + 1, Q.push(v);
}
}
}
if (T != 100000) printf("%d\n", d[n] > 1e8 ? -1 : d[n]);
} else {
for (int i = 1; i <= n; ++i) vis[i] = 0;
priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > pq;
int t = 0;
for (auto x : G[1]) pq.push(make_pair(a[x], x)), vis[x] = 1;
while (!pq.empty()) {
int x = pq.top().second; pq.pop();
if (a[1] + t * A <= a[x]) break;
++t;
for (auto v : G[x]) if (!vis[v]) pq.push(make_pair(a[v], v)), vis[v] = 1;
}
while (!pq.empty()) pq.pop();
for (int i = 1; i <= n; ++i) d[i] = 1e9;
pq.push(make_pair(d[1] = 0, 1));
while (!pq.empty()) {
int x = pq.top().second;
if (pq.top().first != d[x]) {
pq.pop();
continue;
}
pq.pop();
for (auto v : G[x]) {
if (max(d[x], (a[1] + d[x] * A > a[v] ? 0 : (a[v] - a[1] + A) / A)) + 1 < d[v]) {
d[v] = max(d[x], (a[1] + d[x] * A > a[v] ? 0 : (a[v] - a[1] + A) / A)) + 1;
pq.push(make_pair(d[v], v));
}
}
}
if (T != 100000) printf("%d\n", d[n] > t ? -1 : d[n]);
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:12:28: error: ‘n’ was not declared in this scope 12 | for (int te = 1; te <= n; ++te) { | ^ answer.code:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | int T; scanf("%d", &T); | ~~~~~^~~~~~~~~~ answer.code:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:20:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), ((i > 1) && (a[i] += B)); | ~~~~~^~~~~~~~~~~~~