QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110975#6561. Fail FastUSP_USP_USP#WA 2ms3528kbC++231007b2023-06-05 03:09:222023-06-05 03:09:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-05 03:09:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3528kb
  • [2023-06-05 03:09:22]
  • 提交

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.