QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79424#2457. Cheese, If You PleasekexunWA 0ms3824kbC++141.5kb2023-02-20 08:18:132023-02-20 08:18:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 08:18:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2023-02-20 08:18:13]
  • 提交

answer

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;

const int N = 105, M = 105;
const long double eps=1e-10;

int n, m, id[105];
long double a[55][55], ans[55];

void Pivot(int l, int e) {
    swap(id[l + n], id[e]);
    long double t = a[l][e];
    a[l][e]=1;
    for (int i = 0; i <= n; ++i) a[l][i] /= t;
    for (int i = 0; i <= m; ++i)
        if (i != l && fabs(a[i][e]) > eps) {
            t = a[i][e];
            a[i][e] = 0;
            for (int j = 0; j <= n; ++j)
                a[i][j] -= t * a[l][j];
        }
}

bool Simplex() {
    while (1) {
        int l = 0, e = 0;
        long double mn = 1e+50;
        for (int i = 1; i <= n; ++i)
            if (a[0][i] > eps) {
                e = i;
                break;
            }
        if (!e) break;
        for (int i = 1; i <= m; ++i)
            if (a[i][e] > eps && a[i][0] / a[i][e] < mn)
                mn = a[i][0] / a[i][e], l = i;
        if (!l) return false;
        Pivot(l, e);
    }
    return true;
}

int main() {
    cin >> m >> n;
    for (int i = 1; i <= m; ++i) cin >> a[i][0];
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[j][i];
            a[j][i] /= 100;
        }
        cin >> a[0][i];
    }
    for (int i = 1; i <= n; ++i) id[i] = i;
    if (Simplex()) {
        double ans = -a[0][0];
        printf("%.2lf\n", ans + eps);
    }
    else while(1);
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3824kb

input:

4 4
100 0 123 456
10.0 20.0 30.0 40.0 2.56
40.0 0.0 25.0 35.0 3.84
40.0 30.0 20.0 10.0 1.23
33.0 0.0 34.0 33.0 4.23

output:

0.00

result:

wrong answer 1st lines differ - expected: '1281.82', found: '0.00'