QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#545465#7512. Almost Prefix ConcatenationLiangsheng298#WA 1ms3592kbC++141.9kb2024-09-03 13:21:182024-09-03 13:21:18

Judging History

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

  • [2024-09-03 13:21:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2024-09-03 13:21:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(){
    T x=0;char ch=getchar();bool fl=false;
    while(!isdigit(ch)){if(ch=='-')fl=true;ch=getchar();}
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);ch=getchar();
    }
    return fl?-x:x;
}
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define LL long long
#define read() read<int>()
int n;
char s[25];
#define Pair pair<int,int>
set<Pair> S;
map<Pair,int> mp;
void dfs(int de,int x,int y){
    if(de==n+1){
        S.insert(make_pair(x,y));return ;
    }
    if(s[de]=='L'){
        auto t=make_pair(x-1,y);
        if(!mp[t]){
            mp[t]=1;dfs(de+1,t.first,t.second);
            mp[t]=-1;dfs(de+1,x,y);
            mp[t]=0;
        }
        else if(mp[t]==1)dfs(de+1,t.first,t.second);
        else dfs(de+1,x,y);
    }
    else if(s[de]=='R'){
        auto t=make_pair(x+1,y);
        if(!mp[t]){
            mp[t]=1;dfs(de+1,t.first,t.second);
            mp[t]=-1;dfs(de+1,x,y);
            mp[t]=0;
        }
        else if(mp[t]==1)dfs(de+1,t.first,t.second);
        else dfs(de+1,x,y);
    }
    else if(s[de]=='U'){
        auto t=make_pair(x,y+1);
        if(!mp[t]){
            mp[t]=1;dfs(de+1,t.first,t.second);
            mp[t]=-1;dfs(de+1,x,y);
            mp[t]=0;
        }
        else if(mp[t]==1)dfs(de+1,t.first,t.second);
        else dfs(de+1,x,y);
    }
    else {
        auto t=make_pair(x,y-1);
        if(!mp[t]){
            mp[t]=1;dfs(de+1,t.first,t.second);
            mp[t]=-1;dfs(de+1,x,y);
            mp[t]=0;
        }
        else if(mp[t]==1)dfs(de+1,t.first,t.second);
        else dfs(de+1,x,y);
    }
}
int main(){
    FASTIO;
    cin>>n>>(s+1);
    mp[make_pair(0,0)]=true;
    dfs(1,0,0);
    cout<<S.size()<<'\n';
    for(auto t:S)cout<<t.first<<' '<<t.second<<'\n';
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3592kb

input:

ababaab
aba

output:

1
0 0

result:

wrong answer 1st numbers differ - expected: '473', found: '1'