QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#794074 | #9802. Light Up the Grid | xiaoyilang | Compile Error | / | / | C++98 | 1.3kb | 2024-11-30 10:41:02 | 2024-11-30 10:41:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=17;
int T,m;
int a0,a1,a2,a3,h[N][N];
int dp[N][100005];
void init(){
memset(h,0x3f,sizeof(h));
for(int i=0;i<16;i++) h[i][i]=2*min({a0,a1,a2,a3});
for(int i=0;i<16;i++){
for(int j=0;j<16;j++){
int v=(i^(1<<j));
h[i][v]=min(h[i][v],a0);
}
for(int j=0;j<4;j+=2){
int v=(i^(1<<j));
v=(v^(1<<(j+1)));
h[i][v]=min(h[i][v],a1);
}
for(int j=0;j<2;j++){
int v=(i^(1<<j));
v=(v^(1<<(j+2)));
h[i][v]=min(h[i][v],a2);
}
h[i][i^15]=min(h[i][i^15],a3);
}
for(int k=0;k<16;k++){
for(int i=0;i<16;i++){
for(int j=0;j<16;j++)
h[i][j]=min(h[i][j],h[i][k]+h[k][j]);
}
}
memset(dp,0x3f,sizeof(dp));
dp[0][0]=0;
for(int i=0;i<16;i++){
for(int j=0;j<(1<<16);j++){
for(int k=0;k<16;k++){
if((j>>k)&1) continue;
int v=15-(k^i);
dp[i^v][j|(1<<k)]=min(dp[i^v][j|(1<<k)],dp[i][j]+h[0][v]);
}
}
}
}
void solve(){
cin>>m;
int sum=0;
while(m--){
string a,b;
cin>>a>>b;
int v=0;
for(int i=0;i<2;i++){
v=v*2+a[i]-'0';
}
for(int i=0;i<2;i++){
v=v*2+b[i]-'0';
}
sum+=(1<<v);
}
int ans=1e9;
for(int i=0;i<16;i++) ans=min(ans,dp[i][sum]);
cout<<ans<<'\n';
}
int main(){
int T;
cin>>T>>a0>>a1>>a2>>a3;
init();
while(T--) solve();
return 0;
}
詳細信息
answer.code: In function ‘void init()’: answer.code:9:45: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 9 | for(int i=0;i<16;i++) h[i][i]=2*min({a0,a1,a2,a3}); | ^ answer.code:9:44: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’ 9 | for(int i=0;i<16;i++) h[i][i]=2*min({a0,a1,a2,a3}); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:9:44: note: candidate expects 2 arguments, 1 provided 9 | for(int i=0;i<16;i++) h[i][i]=2*min({a0,a1,a2,a3}); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:9:44: note: candidate expects 3 arguments, 1 provided 9 | for(int i=0;i<16;i++) h[i][i]=2*min({a0,a1,a2,a3}); | ~~~^~~~~~~~~~~~~~~