QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660086 | #3488. Assassins | DEtermination21# | WA | 1ms | 3772kb | C++14 | 1.6kb | 2024-10-20 05:22:53 | 2024-10-20 05:22:53 |
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";
if (m == 0)
for (double a : p)
cout << a << endl;
else {
vector<double> ans = solve(p, 0, m, 1);
for (double a : ans)
cout << a << endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
4 3 1 2 0.25 1 4 0.42 2 3 1.0
output:
0 1 1 1 1 1 1 0 0.58 1 0 1 0.58 1 1 0 1 1 1 0 1 1 1 0 1 0 2 1 0 1 0 1 0 1 0 1 0 0 0 2 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 2 1 1 1 0 1 1 1 0 1 1 0 0 3 1 1 0 0 1 1 0 0 0 1 0 0 3 1 1 1 0 1 1 1 0 0 1 1 0 2 1 1 1 1 1 1 1 1 1 1 0 1 3 1 1 0 1 1 1 0 1 0 1 0 1 3 1 ...
result:
wrong answer 1st numbers differ - expected: '1.0000000', found: '0.0000000', error = '1.0000000'