QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#361349#3400. 重建Pengzt0 1ms4036kbC++141.5kb2024-03-23 09:00:112024-03-23 09:00:12

Judging History

This is the latest submission verdict.

  • [2024-03-23 09:00:12]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 4036kb
  • [2024-03-23 09:00:11]
  • Submitted

answer

#include<bits/stdc++.h>
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define pb emplace_back
using namespace std;
#define db double
const db eps = 1e-7;
int n;
db a[110][110], ans = 1;
double det(int n) {
  cout << fixed << setprecision(5);
//  cout << "Matrix A: \n";
//  for(int i = 1; i <= n; ++i, cout << "\n") 
//    for(int j = 1; j <= n; ++j)
//      cout << a[i][j] << " ";
  int coef = 0;
  for(int i = 1; i <= n; ++i) {
    int p = i;
    for(int j = 1; j <= n; ++j)
      if(fabs(a[j][i]) > fabs(a[p][i]))
        p = j;
    if(i ^ p)
      swap(a[i], a[p]), coef ^= 1;
    if(fabs(a[i][i]) < eps)
      cout << "?\n", exit(0);
    for(int j = i + 1; j <= n; ++j)
      if(i != j && fabs(a[j][i]) > eps) {
        db t = a[j][i] / a[i][i];
        for(int k = n; k >= i; --k)
          a[j][k] -= t * a[i][k];
      }
  }
  db ret = 1;
  for(int i = 1; i <= n; ++i)
    ret *= a[i][i];
  return !coef ? ret : -ret;
}
int main() {
  ios :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= n; ++j) {
      cin >> a[i][j];
      if(i < j)
        ans *= (1 - a[i][j]);
      if(fabs(1 - a[i][j]) < eps)
        a[i][j] = 1 - eps;
      else
        a[i][j] = a[i][j] / (1 - a[i][j]);
    }
  for(int i = 1; i <= n; ++i) {
    a[i][i] = 0;
    for(int j = 1; j <= n; ++j)
      if(i ^ j)
        a[i][i] += a[i][j], a[i][j] *= -1;
  }
  ans *= det(n - 1);
  cout << ans << "\n";
  return 0;
}

詳細信息

Test #1:

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

input:

10
0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 1.00 0.00 1.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 1.00
1.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0....

output:

-0.00000

result:

wrong answer 1st numbers differ - expected: '1.00000', found: '-0.00000', error = '1.00000'

Test #2:

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

input:

8
0.0 1.0 0.25 0.875 0.0 0.25 1.0 0.25
1.0 0.0 0.0 0.25 0.0 0.0 0.0 0.25
0.25 0.0 0.0 0.0 0.0 0.875 0.125 0.0
0.875 0.25 0.0 0.0 0.0 0.125 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
0.25 0.0 0.875 0.125 0.0 0.0 1.0 1.0
1.0 0.0 0.125 0.0 1.0 1.0 0.0 0.125
0.25 0.25 0.0 0.0 0.0 1.0 0.125 0.0 0.0 0.0

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.13884', found: '0.00000', error = '0.13884'

Test #3:

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

input:

7
0.0 1.0 0.0 1.0 0.0 1.0 0.0
1.0 0.0 0.375 0.25 0.0 0.0 1.0
0.0 0.375 0.0 0.25 0.0 1.0 0.125
1.0 0.25 0.25 0.0 0.75 0.125 0.0
0.0 0.0 0.0 0.75 0.0 0.0 0.0
1.0 0.0 1.0 0.125 0.0 0.0 0.0
0.0 1.0 0.125 0.0 0.0 0.0 0.0 0.0 0.0

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.20187', found: '0.00000', error = '0.20187'

Test #4:

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

input:

10
0.00 0.02 1.00 0.03 0.03 0.80 0.03 0.03 0.80 0.90
0.02 0.00 0.02 0.02 0.04 0.90 0.04 0.01 0.04 0.02
1.00 0.02 0.00 0.02 0.80 0.35 0.80 1.00 0.02 0.01
0.03 0.02 0.02 0.00 0.04 1.00 0.01 0.90 0.02 0.01
0.03 0.04 0.80 0.04 0.00 0.02 0.90 0.03 1.00 0.35
0.80 0.90 0.35 1.00 0.02 0.00 0.03 0.02 0.03 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00608', found: '0.00000', error = '0.00608'

Test #5:

score: 0
Wrong Answer
time: 1ms
memory: 3888kb

input:

12
0.00 0.02 0.30 0.20 0.30 0.20 0.21 0.21 0.20 0.21 0.30 0.65
0.02 0.00 0.20 0.60 1.00 0.20 0.20 0.21 0.20 0.30 0.02 0.30
0.30 0.20 0.00 0.20 0.02 0.60 0.20 0.02 0.65 0.20 0.21 0.02
0.20 0.60 0.20 0.00 0.20 0.20 0.20 0.30 0.65 0.60 0.02 0.21
0.30 1.00 0.02 0.20 0.00 0.21 0.30 1.00 0.20 0.60 0.21 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00014', found: '0.00000', error = '0.00014'

Test #6:

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

input:

16
0.0 0.25 0.0 0.0 1.0 0.75 0.0 0.0 1.0 0.125 0.0 0.25 0.0 0.0 0.25 0.0
0.25 0.0 0.0 0.0 0.0 0.125 0.0 0.0 0.0 0.125 0.875 0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 0.25 0.125 0.375 1.0 0.0 0.375 0.25 0.0 1.0 0.25 0.0 0.125
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.25 0.0 1.0 0.0 0.0 0.0 0.0 0.0
1.0 0.0 0.25 0.0...

output:

-0.00000

result:

wrong answer 1st numbers differ - expected: '0.00010', found: '-0.00000', error = '0.00010'

Test #7:

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

input:

16
0.00 0.07 0.07 0.10 0.18 0.10 0.02 0.10 0.15 0.10 0.18 0.15 1.00 0.02 0.18 0.15
0.07 0.00 0.87 0.65 0.07 0.07 0.10 0.02 0.07 0.15 0.02 0.15 0.10 0.18 0.90 0.02
0.07 0.87 0.00 0.10 0.07 0.07 0.15 0.07 0.02 0.10 0.02 0.65 0.07 0.65 0.02 0.07
0.10 0.65 0.10 0.00 0.10 0.02 0.10 0.07 0.15 0.02 0.18 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00015', found: '0.00000', error = '0.00015'

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 4036kb

input:

45
0.00 0.00 0.00 0.00 0.00 0.00 0.02 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.98 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.02 0.02 0.00 0.00 0.00 0.01 0.02 0.00 0.02 0.90
0.00 0.00 0.00 0.00 0.00 0.01 0.01 0.01 0.01 0.01 0.02 0.00 0.00 0.00 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00024', found: '0.00000', error = '0.00024'

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3904kb

input:

40
0.00 0.00 0.02 0.01 0.00 0.00 0.02 0.00 0.00 0.00 0.02 0.01 0.00 0.01 0.00 0.95 0.00 0.02 0.01 0.00 0.90 0.01 0.01 0.02 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.01 0.01 0.02 0.00 0.00 0.02 0.00
0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.01 0.00 0.00 0.00 0.00 0.02 0.00 0.01 0.01 0.00 0.02 0.00 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00033', found: '0.00000', error = '0.00033'

Test #10:

score: 0
Wrong Answer
time: 1ms
memory: 3904kb

input:

45
0.00 0.90 0.00 0.02 0.00 0.00 0.00 0.02 0.01 0.90 0.96 0.00 0.00 0.00 0.00 0.00 0.02 0.01 0.00 0.00 0.02 0.00 0.01 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.90 0.00 0.00 0.00 0.98 0.00 0.01 0.00 0.02 0.00 0.00
0.90 0.00 0.00 0.00 0.00 0.00 0.02 0.00 0.00 0.00 0.01 0.02 0.00 0.00 0....

output:

0.00000

result:

wrong answer 1st numbers differ - expected: '0.00011', found: '0.00000', error = '0.00011'