QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110975 | #6561. Fail Fast | USP_USP_USP# | WA | 2ms | 3528kb | C++23 | 1007b | 2023-06-05 03:09:22 | 2023-06-05 03:09:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define pb push_back
void dbg_out() { cerr << endl; }
template<typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
void solve() {
int n; cin >> n;
vector<int> in(n), c(n), nxt(n);
vector<double> p(n);
set<pair<double, int>> free;
for(int i=0;i<n;i++) {
cin >> c[i] >> p[i] >> nxt[i];
nxt[i]--;
if(nxt[i] != -1) in[nxt[i]]++;
}
for(int i=0;i<n;i++) if(in[i] == 0) {
free.emplace(p[i] / c[i], i);
}
vector<int> ord;
while(!free.empty()) {
auto [_, i] = *free.rbegin();
ord.pb(i);
free.erase(*free.rbegin());
if(nxt[i] != -1) {
int j = nxt[i];
in[j]--;
if(in[j] == 0) {
free.emplace(p[j] / c[j], j);
}
}
}
for(int i: ord) {
cout << i+1 << '\n';
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3528kb
input:
4 100 0.5 0 200 0.1 1 10 0.5 2 10 0.9 0
output:
4 3 2 1
result:
wrong answer Test 3 wrongly executed before test 2.