QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102398#5250. Combination Lockszswzswzsw#Compile Error//C++14791b2023-05-03 12:42:392023-05-03 12:42:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 12:42:41]
  • 评测
  • [2023-05-03 12:42:39]
  • 提交

answer

#include<iostream>
using namespace std;
const int N=2500;

int f[N];
int n,c;

int get_id(string &s){
    int ans=0;
    for(int i=0;i<s.size();++i)
        ans|=((s[i]=='=')<<i);
    return ans;
}

bool dfs(int k){
    if(f[k]!=-1)return f[k];
    bool res=0;
    for(int i=0;i<n;++i)
        if(!(k&(1<<i)))
            res|=!dfs(k|(1<<i));
    return f[k]=res;
}

int main(){
    int T;
    cin>>T;
    while(T--){
        memset(f,-1,sizeof(f));
        cin>>n>>c;
        string a,b,x;
        cin>>a>>b;
        for(int i=0;i<n;++i)
            x.push_back(a[i]==b[i]?'=':'.');
        int st=get_id(x);
        for(int i=1;i<=c;++i){
            cin>>x;
            f[get_id(x)]=1;
        }
        cout<<(dfs(st)?"Alice":"Bob")<<endl;
    }
}

Details

answer.code: In function ‘int main()’:
answer.code:28:9: error: ‘memset’ was not declared in this scope
   28 |         memset(f,-1,sizeof(f));
      |         ^~~~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;