QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660086#3488. AssassinsDEtermination21#WA 1ms3772kbC++141.6kb2024-10-20 05:22:532024-10-20 05:22:53

Judging History

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

  • [2024-10-20 05:22:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-10-20 05:22:53]
  • 提交

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'