QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111134 | #6561. Fail Fast | KhNURE_KIVI# | WA | 2ms | 6848kb | C++20 | 3.0kb | 2023-06-05 22:15:13 | 2023-06-05 22:15:17 |
Judging History
answer
//#pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")
#ifdef __APPLE__
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
#else
#include <bits/stdc++.h>
#endif
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
template<typename T>
bool umin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<typename T>
bool umax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
#if __APPLE__
#define D for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template <class ...Ts> auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define D while (false)
#define LOG(...)
#endif
const int max_n = 1e5+10, inf = 1000111222;
struct e
{
ld p;
int c;
int id;
};
const bool operator<(const e& lhs,const e& rhs)
{
LOG((1-lhs.p)*lhs.c+lhs.p*(1-rhs.p)*(lhs.c+rhs.c), (1-rhs.p)*rhs.c+rhs.p*(1-lhs.p)*(lhs.c+rhs.c));
return (1-lhs.p)*lhs.c+lhs.p*(1-rhs.p)*(lhs.c+rhs.c) < (1-rhs.p)*rhs.c+rhs.p*(1-lhs.p)*(lhs.c+rhs.c);
}
vector<int> backreb[max_n];
int cnt[max_n];
e E[max_n];
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
set<e> setik;
for (int i=1;i<=n;i++){
int c;
ld p;
int d;
cin>>c>>p>>d;
E[i]=e{p,c,i};
if (d!=0){
cnt[d]++;
backreb[i].pb(d);
}
}
LOG(E[3]<E[4]);
for (int i=1;i<=n;i++){
if (cnt[i]==0){
LOG(i);
setik.insert(E[i]);
}
}
vector<int> ans;
while (!setik.empty()){
e now=*setik.rbegin();
setik.erase(--setik.end());
ans.pb(now.id);
LOG(now.id);
for (auto wh:backreb[now.id]){
cnt[wh]--;
if (cnt[wh]==0){
setik.insert(E[wh]);
}
}
}
reverse(all(ans));
for (auto i:ans){
cout<<i<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 6848kb
input:
4 100 0.5 0 200 0.1 1 10 0.5 2 10 0.9 0
output:
1 2 3 4
result:
wrong answer your plan is not optimal