QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660083 | #3488. Assassins | DEtermination21# | RE | 0ms | 3884kb | C++14 | 1.5kb | 2024-10-20 05:14:58 | 2024-10-20 05:14:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<int> ai, aj;
vector<double> ap;
void print (vector<double> a) {
for (double i : a)
cout << i << " ";
cout << "\n";
}
vector<double> add (vector<double> a, vector<double> b) {
vector<double> ans(a.size());
for(int i = 0; i < a.size(); i++)
ans[i] = a[i] + b[i];
return ans;
}
vector<double> times (double k, vector<double> a) {
for(int i = 0; i < a.size(); i++)
{
a[i] = a[i] * k;
}
return a;
}
vector<double> solve(vector<double> p, int a, int m, bool x) {
if (a > m)
return p;
vector<double> kp(p);
kp[aj[a]] = 0;
if(x) {
//cout << a << ": " << ai[a] << " " << aj[a] << " " << ap[a] << "\n";
cout << a << "\n";
print(p);
print(solve(p, a+1, m, 0));
print(solve(kp, a+1, m, 0));
}
if(p[ai[a]] == 0)
return p;
return add(times((1-ap[a]), solve(p, a+1, m, x)), times(ap[a], solve(kp, a+1, m, x)));
}
int main()
{
int n, m;
cin >> n >> m;
vector<double> p(n, 1);
ai = vector<int>(m);
aj = vector<int>(m);
ap = vector<double>(m);
for (int a = 0; a < m; a++) // ath assasination attempt
{
cin >> ai[a] >> aj[a] >> ap[a];
aj[a]--;
ai[a]--;
}
//cout << "\n";
vector<double> ans = solve(p, 0, m, 0);
//print(ans);
for (double p : ans)
cout << p << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
4 3 1 2 0.25 1 4 0.42 2 3 1.0
output:
1 0.75 0.25 0.58
result:
ok 4 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
2 3 1 2 0.23 2 1 0.99 1 2 0.99
output:
0.2377 0.762377
result:
ok 2 numbers
Test #3:
score: -100
Runtime Error
input:
1 0