QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#660083#3488. AssassinsDEtermination21#RE 0ms3884kbC++141.5kb2024-10-20 05:14:582024-10-20 05:14:59

Judging History

你现在查看的是最新测评结果

  • [2024-10-20 05:14:59]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3884kb
  • [2024-10-20 05:14:58]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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

output:


result: