QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104723#6406. Stage Cleargapinho#WA 2ms3428kbC++201.1kb2023-05-11 20:00:032023-05-11 20:00:06

Judging History

This is the latest submission verdict.

  • [2024-08-15 21:05:17]
  • hack成功,自动添加数据
  • (/hack/778)
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-11 20:00:06]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3428kb
  • [2023-05-11 20:00:03]
  • Submitted

answer

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int mx = 112;
typedef pair<int, int> ii;
vector<int> adj[mx];
int A[mx], B[mx], n;

bool check (int hp) {
  vector<bool> inq(mx, 0);
  priority_queue<ii> pq;
  pq.emplace(0, 0);
  while (!pq.empty()) {
    auto[w, v] = pq.top();
    inq[v] = true;
    hp += w;
    pq.pop();
    for (int i = 0; i < n; i++) {
      if (inq[i]) {
        for (auto u : adj[i]) {
          if (!inq[u] && A[u] <= hp) {
            pq.emplace(B[u] - A[u], u);
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!inq[i]) return 0;
  }
  return 1;
}

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m;
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    cin >> A[i] >> B[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].emplace_back(b);
  }
  int lo = 0, hi = 1e18;
  while (hi - lo > 1) {
    int mid = (lo+hi)/2;
    if (check(mid)) hi = mid;
    else lo = mid;
  }
  if (hi < lo) swap(lo, hi);
  if (check(lo)) cout << lo << endl;
  else cout << hi << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3416kb

input:

4 4
4 2
5 3
2 6
1 2
1 3
2 4
3 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3428kb

input:

15 14
254040392438309 117083115436273
500005748229691 557255157630172
821034233718230 865199673774998
659892147898798 987564141425694
81172575487567 811635577877255
751768357864605 341103322647288
454926350150218 140191090713900
921608121471585 659295670987251
223751724062143 505619245326640
8907765...

output:

900742101319785

result:

wrong answer 1st numbers differ - expected: '1665396301509143', found: '900742101319785'