QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111142 | #6563. Four Square | KhNURE_KIVI# | WA | 1ms | 9540kb | C++20 | 3.2kb | 2023-06-05 23:02:11 | 2023-06-05 23:02:13 |
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)
{
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<e> reb[max_n];
e E[max_n];
int T;
int tin[max_n];
int tout[max_n];
void dfs(int now)
{
tin[now]=T++;
for (auto wh:reb[now]){
dfs(wh.id);
}
tout[now]=T;
LOG(now,tin[now],tout[now]);
}
bool is_pred(int a,int b)
{
return tin[a]<=tin[b] && tout[a]>=tout[b];
}
const bool cmp(const int& lhs,const int& rhs)
{
if (is_pred(lhs,rhs)){
return true;
}
if (is_pred(rhs,lhs)){
return false;
}
return E[lhs]<E[rhs];
}
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;
// if (d==0){
// setik.insert(e{p,c,i});
// }
reb[d].pb(e{p,c,i});
E[i]=e{p,c,i};
}
dfs(0);
vector<int> p;
for (int i=1;i<=n;i++){
p.pb(i);
}
sort(all(p),cmp);
for (auto i:p){
cout<<i<<"\n";
}
// while (!setik.empty()){
// e now=*setik.begin();
// setik.erase(setik.begin());
// cout<<now.id<<"\n";
// for (auto wh:reb[now.id]){
// setik.insert(wh);
// }
// }
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6892kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 9540kb
input:
3 1 3 3 2 2 3 3
output:
3 2 1
result:
wrong answer 1st lines differ - expected: '0', found: '3'