QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110974#6561. Fail FastUSP_USP_USP#WA 0ms3600kbC++231005b2023-06-05 03:09:042023-06-05 03:09:07

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:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2023-06-05 03:09:04]
  • 提交

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.