QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110974 | #6561. Fail Fast | USP_USP_USP# | WA | 0ms | 3600kb | C++23 | 1005b | 2023-06-05 03:09:04 | 2023-06-05 03:09:07 |
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.begin();
ord.pb(i);
free.erase(*free.begin());
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: 0ms
memory: 3600kb
input:
4 100 0.5 0 200 0.1 1 10 0.5 2 10 0.9 0
output:
3 2 1 4
result:
wrong answer Test 3 wrongly executed before test 2.