QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#265552 | #7753. Energy Distribution | ucup-team022# | WA | 1ms | 3860kb | C++14 | 724b | 2023-11-25 19:20:43 | 2023-11-25 19:20:48 |
Judging History
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.999;
while(T>=1e-6){
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: 1ms
memory: 3784kb
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: 1ms
memory: 3852kb
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: 1ms
memory: 3860kb
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: -100
Wrong Answer
time: 1ms
memory: 3856kb
input:
4 0 3 1 0 3 0 1 0 1 1 0 2 0 0 2 0
output:
0.749997
result:
wrong answer 1st numbers differ - expected: '0.7500000', found: '0.7499970', error = '0.0000030'