QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#660094 | #3488. Assassins | DEtermination21# | TL | 0ms | 4004kb | C++14 | 1.6kb | 2024-10-20 05:28:20 | 2024-10-20 05:28:22 |
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, 0);
for (double a : ans)
cout << a << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4004kb
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: 3904kb
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: 0
Accepted
time: 0ms
memory: 3784kb
input:
1 0
output:
1
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
15 0
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok 15 numbers
Test #5:
score: -100
Time Limit Exceeded
input:
13 789 9 10 0.929912 13 10 0.914159 10 8 0.387852 8 11 0.486651 1 8 0.670384 5 13 0.827703 10 7 0.245216 3 6 0.201279 3 2 0.803532 1 11 0.412332 9 8 0.389861 6 10 0.381930 10 9 0.757771 2 4 0.307478 1 4 0.743987 13 1 0.806574 1 9 0.227402 9 12 0.465246 9 13 0.704373 5 12 0.455770 10 7 0.494139 4 6 0...