QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317058 | #7753. Energy Distribution | Register | Compile Error | / | / | C++14 | 1.2kb | 2024-01-28 13:44:58 | 2024-01-28 13:44:59 |
Due to the privacy settings of the submitter, you are not allowed to view this code.
Details
answer.code: In function ‘int main()’: answer.code:2:522: error: missing template arguments before ‘w’ 2 | constexpr double eps=1e-8;int dcmp(double x){return x<-eps?-1:x>eps;}bool gauss(std::vector<std::vector<double>>&a){int n=a.size();for(int i=0;i<n;i++){int tar=-1;for(int j=i;j<n;j++){if(dcmp(a[j][i])){tar=j;break;}}if(tar==-1)return false;std::swap(a[i],a[tar]);double div=a[i][i];for(int j=i;j<=n;j++)a[i][j]/=div;for(int j=0;j<n;j++){if(i==j)continue;div=a[j][i];for(int k=i;k<=n;k++){a[j][k]-=a[i][k]*div;}}}return true;}int main(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;std::cin>>n;std::vector w(n,std::vector<double>(n));for(int i=0;i<n;i++)for(int j=0;j<n;j++)std::cin>>w[i][j];double ans=0;for(int s=0;s<(1<<n);s++){int m=__builtin_popcount(s);if(m<=1)continue;std::vector<int>b;for(int i=0;i<n;i++)if(s>>i&1)b.push_back(i);std::vector f(m,std::vector<double>(m+1));for(int i=0;i<=m;i++)f[0][i]=1;for(int i=1;i<m;i++){for(int j=0;j<m;j++){f[i][j]=w[b[i]][b[j]]-w[b[i-1]][b[j]];}}if(gauss(f)){double res=0;bool ok=true;for(int i=0;i<m;i++){if(dcmp(f[i][m])<=0){ok=false;break;}}if(ok){for(int i=0;i<m;i++){for(int j=i+1;j<m;j++){res+=f[i][m]*f[j][m]*w[b[i]][b[j]];}}ans=std::max(ans,res);}}}std::cout<<std::fixed<<std::setprecision(6)<<ans<<"\n";return 0;} | ^ answer.code:2:600: error: ‘w’ was not declared in this scope 2 | constexpr double eps=1e-8;int dcmp(double x){return x<-eps?-1:x>eps;}bool gauss(std::vector<std::vector<double>>&a){int n=a.size();for(int i=0;i<n;i++){int tar=-1;for(int j=i;j<n;j++){if(dcmp(a[j][i])){tar=j;break;}}if(tar==-1)return false;std::swap(a[i],a[tar]);double div=a[i][i];for(int j=i;j<=n;j++)a[i][j]/=div;for(int j=0;j<n;j++){if(i==j)continue;div=a[j][i];for(int k=i;k<=n;k++){a[j][k]-=a[i][k]*div;}}}return true;}int main(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;std::cin>>n;std::vector w(n,std::vector<double>(n));for(int i=0;i<n;i++)for(int j=0;j<n;j++)std::cin>>w[i][j];double ans=0;for(int s=0;s<(1<<n);s++){int m=__builtin_popcount(s);if(m<=1)continue;std::vector<int>b;for(int i=0;i<n;i++)if(s>>i&1)b.push_back(i);std::vector f(m,std::vector<double>(m+1));for(int i=0;i<=m;i++)f[0][i]=1;for(int i=1;i<m;i++){for(int j=0;j<m;j++){f[i][j]=w[b[i]][b[j]]-w[b[i-1]][b[j]];}}if(gauss(f)){double res=0;bool ok=true;for(int i=0;i<m;i++){if(dcmp(f[i][m])<=0){ok=false;break;}}if(ok){for(int i=0;i<m;i++){for(int j=i+1;j<m;j++){res+=f[i][m]*f[j][m]*w[b[i]][b[j]];}}ans=std::max(ans,res);}}}std::cout<<std::fixed<<std::setprecision(6)<<ans<<"\n";return 0;} | ^ answer.code:2:767: error: missing template arguments before ‘f’ 2 | constexpr double eps=1e-8;int dcmp(double x){return x<-eps?-1:x>eps;}bool gauss(std::vector<std::vector<double>>&a){int n=a.size();for(int i=0;i<n;i++){int tar=-1;for(int j=i;j<n;j++){if(dcmp(a[j][i])){tar=j;break;}}if(tar==-1)return false;std::swap(a[i],a[tar]);double div=a[i][i];for(int j=i;j<=n;j++)a[i][j]/=div;for(int j=0;j<n;j++){if(i==j)continue;div=a[j][i];for(int k=i;k<=n;k++){a[j][k]-=a[i][k]*div;}}}return true;}int main(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;std::cin>>n;std::vector w(n,std::vector<double>(n));for(int i=0;i<n;i++)for(int j=0;j<n;j++)std::cin>>w[i][j];double ans=0;for(int s=0;s<(1<<n);s++){int m=__builtin_popcount(s);if(m<=1)continue;std::vector<int>b;for(int i=0;i<n;i++)if(s>>i&1)b.push_back(i);std::vector f(m,std::vector<double>(m+1));for(int i=0;i<=m;i++)f[0][i]=1;for(int i=1;i<m;i++){for(int j=0;j<m;j++){f[i][j]=w[b[i]][b[j]]-w[b[i-1]][b[j]];}}if(gauss(f)){double res=0;bool ok=true;for(int i=0;i<m;i++){if(dcmp(f[i][m])<=0){ok=false;break;}}if(ok){for(int i=0;i<m;i++){for(int j=i+1;j<m;j++){res+=f[i][m]*f[j][m]*w[b[i]][b[j]];}}ans=std::max(ans,res);}}}std::cout<<std::fixed<<std::setprecision(6)<<ans<<"\n";return 0;} | ...