QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265560#7753. Energy Distributionucup-team022#WA 73ms3896kbC++14726b2023-11-25 19:22:352023-11-25 19:22:45

Judging History

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

  • [2024-10-31 10:22:30]
  • hack成功,自动添加数据
  • (/hack/1089)
  • [2023-11-25 19:22:45]
  • 评测
  • 测评结果:WA
  • 用时:73ms
  • 内存:3896kb
  • [2023-11-25 19:22:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

double res[15];
double w[15][15];
double sum;
int n;

void calc(){
    sum=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            sum+=res[i]*res[j]*w[i][j];  
}

int main(){
    res[1]=1;
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>w[i][j];
    double T = 1;
    double delta = 0.99999;
    while(T>=1e-9){
        int x = rand() % n + 1, y = rand() % n + 1;
        double nres = sum;
        double d = min({T,res[x]});
        res[x] -= d;
        res[y] += d;
        calc();
        if(sum<nres)res[x]+=d,res[y]-=d;
        T *= delta;
    }
    calc();
    cout << sum << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 44ms
memory: 3892kb

input:

2
0 1
1 0

output:

0.25

result:

ok found '0.2500000', expected '0.2500000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 54ms
memory: 3832kb

input:

3
0 2 1
2 0 2
1 2 0

output:

0.571429

result:

ok found '0.5714290', expected '0.5714290', error '0.0000000'

Test #3:

score: 0
Accepted
time: 57ms
memory: 3884kb

input:

3
0 1 2
1 0 1
2 1 0

output:

0.5

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 60ms
memory: 3884kb

input:

4
0 3 1 0
3 0 1 0
1 1 0 2
0 0 2 0

output:

0.75

result:

ok found '0.7500000', expected '0.7500000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 69ms
memory: 3896kb

input:

5
0 0 0 4 4
0 0 2 0 4
0 2 0 2 0
4 0 2 0 0
4 4 0 0 0

output:

1

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #6:

score: -100
Wrong Answer
time: 73ms
memory: 3868kb

input:

6
0 9 5 5 10 6
9 0 0 0 0 1
5 0 0 0 3 0
5 0 0 0 10 5
10 0 3 10 0 0
6 1 0 5 0 0

output:

2.85714

result:

wrong answer 1st numbers differ - expected: '2.8571430', found: '2.8571400', error = '0.0000010'