QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613084#4795. Taxiucup-team4153#WA 0ms3808kbC++201.9kb2024-10-05 13:32:432024-10-05 13:33:01

Judging History

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

  • [2024-10-05 13:33:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-10-05 13:32:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
map<string,bool>mp;
bool solve(string s){
    if(mp.find(s)!=mp.end())return mp[s];
    if(s=="1")return mp[s]=false;
    int cnt=0;
    for(auto ch:s)if(ch=='1')cnt++;
    if(cnt==0)return mp[s]=true;
//    if(cnt==1 && (s[0]=='1' || s[s.length()-1]=='1'))return mp[s]=true;

    if(solve(s.substr(1,s.length()-1)) && solve(s.substr(0,s.length()-1)))return mp[s]=false;
    return mp[s]=true;
}
string trans(string s){
    int cnt=0,len=s.length();
    string res="";
    for(int i=0;i<len;i++){
//        if(s[i]=='0')res.push_back('0');
//        else cnt++;
        cnt++;
        if(i==len-1 || s[i]!=s[i+1]){
//            for(int j=0;j<cnt;j++)res.push_back(s[i]);
            if(cnt&1)res.push_back(s[i]);
            cnt=0;
        }
    }
    return res;
}
map<string,int>ans;
void dfs(int pos,string s,int one,int pre){
    if(pos==10)return;
    if(one&1) {
        solve(s);
//        cout << s << ' '<<s.length() << ' ' << mp[s] << '\n';
        string tmp=trans(s);
        while(tmp!=trans(tmp))tmp=trans(tmp);
//        if(ans.find(tmp)==ans.end())ans[tmp]=mp[s];
//        else if(ans[tmp]!=mp[s]){
//            cout<<s<<' '<<tmp<<' '<<mp[s]<<'\n';
//        }
        if(tmp.length()&1){
            if(mp[s]==1){
                cout<<s<<' '<<tmp<<' '<<mp[s]<<'\n';
            }
        }else{
            if(mp[s]==0){
                cout<<s<<' '<<tmp<<' '<<mp[s]<<'\n';
            }
        }
    }
    if(pre!=1)dfs(pos+1,s+"1",one+1,1);//
    if(pre!=0) dfs(pos+1,s+"0",one,0);//
}
signed main(){
//    string s="12345";
//    cout<<s.substr(1,3);
    dfs(0,"",0,-1);
//    for(auto x:mp){
//        if(x.first.length()==8)
//            cout<<x.first<<' '<<x.second<<'\n';
//    }
//    for(auto x:ans){
//        cout<<x.first<<' '<<x.second<<'\n';
//    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3808kb

input:

2500 2500
531 1977 7285
705 44 4544
1409 2220 8896
2175 2086 9343
1947 729 2482
1114 1832 186
2388 1775 9841
1028 2097 7734
1949 2130 1115
407 1801 352
1165 254 8847
625 844 9853
551 1980 457
1683 163 7785
864 2338 1532
1214 1578 2055
387 1525 797
2070 1976 910
248 568 1444
2434 509 7641
2100 1779 6...

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements