/ tabris /

记录详情

Wrong Answer

/in/foo.cc: In function 'void solve(int, int, int, int, int, int)':
/in/foo.cc:75:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                     ^~~
/in/foo.cc:76:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:100:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                     ^~~
/in/foo.cc:101:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:56:16: warning: variable 't2' set but not used [-Wunused-but-set-variable]
         int t1,t2;
                ^~
/in/foo.cc:145:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                 ^~~
/in/foo.cc:146:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:170:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                 ^~~
/in/foo.cc:171:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:126:13: warning: variable 't1' set but not used [-Wunused-but-set-variable]
         int t1,t2;
             ^~
/in/foo.cc:38:9: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     int x,y;
         ^
/in/foo.cc:38:11: warning: variable 'y' set but not used [-Wunused-but-set-variable]
     int x,y;
           ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:207:18: warning: variable 'pos2' set but not used [-Wunused-but-set-variable]
         int pos1,pos2;
                  ^~~~
/in/foo.cc: In function 'void solve(int, int, int, int, int, int)':
/in/foo.cc:72:18: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if(str[p2]=='[')
            ~~~~~~^
/in/foo.cc:127:16: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int p1,p2;
                ^~
/in/foo.cc:189:26: warning: 'tt2' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c,d-o2+1,pos2+3,p2-1);
                         ~^~~
/in/foo.cc:181:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     tt2=cal(pp1+1,i-1);
                         ~~~^~~~~~~~~~~
/in/foo.cc:164:26: warning: 'tt2' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c,d-o2+1,pos2+3,R);
                         ~^~~
/in/foo.cc:156:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     tt2=cal(pp1+1,i-1);
                         ~~~^~~~~~~~~~~
/in/foo.cc:162:23: warning: 't2' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int hh = b+t2-1;
                      ~^~~
/in/foo.cc:137:23: warning: 'p1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 t2=cal(p1+1,i-1);
                    ~~~^~~~~~~~~~
/in/foo.cc:119:26: warning: 'tt1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c,d-o2+1,pos2+3,p2-1);
                         ~^~~
/in/foo.cc:94:26: warning: 'tt1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c,d-o2+1,pos2+3,R);
                         ~^~~
/in/foo.cc:92:23: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int hh = a+t1-1;
                      ~^~~
/in/foo.cc:128:24: warning: 'pos2' may be used uninitialized in this function [-Wmaybe-uninitialized]
         for(int i=pos2+3;i<=r;i++)
                        ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:217:22: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 m=cal(pos1+1,i-1);
                   ~~~^~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 684.0 KiB
#2 Wrong Answer 1ms 716.0 KiB
#3 Wrong Answer 1ms 476.0 KiB
#4 Wrong Answer 3ms 724.0 KiB
#5 Wrong Answer 1ms 344.0 KiB
#6 Wrong Answer 2ms 600.0 KiB
#7 Wrong Answer 1ms 348.0 KiB
#8 Wrong Answer 1ms 596.0 KiB
#9 Accepted 2ms 472.0 KiB
#10 Wrong Answer 1ms 460.0 KiB

代码

#include<stdio.h>
#include<string.h>

using namespace std;

const int maxn = 1005;
int rr[100005];
char ans[maxn][maxn];
char str[100005];
int cal(int l,int r)
{
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        ans=ans*10+str[i]-'0';
    }
    return ans;
}
void change(int x,int y,int flag)
{
   // dbg3(x,y,flag);
    if(flag==0)
    {
        if(ans[x][y]==' ') ans[x][y]='-';
        else if(ans[x][y]=='|') ans[x][y]='+';
    }
    else
    {
        if(ans[x][y]==' ') ans[x][y]='|';
        else if(ans[x][y]=='-') ans[x][y]='+';
    }
}
void solve(int a,int b,int c,int d,int l,int r)
{
    //dbg3(a,b,c);
    //dbg3(d,l,r);
    if(str[r]>='0'&&str[r]<='9') return ;
    int x,y;
    int pos1,pos2;
    for(int i=l;i<=r;i++)
    {
        if(str[i]=='x')
        {
            x=cal(l,i-1);
            pos1=i;
        }
        if(str[i]=='[')
        {
            y=cal(pos1+1,i-1);
            pos2=i;
            break;
        }
    }
    if(str[pos2+1]=='-')
    {
        int t1,t2;
        int p1,p2;
        for(int i=pos2+3;i<=r;i++)
        {
            if(str[i]=='x')
            {
                t1=cal(pos2+3,i-1);
                p1=i;
            }
            if(str[i]=='['||str[i]==',')
            {
                t2=cal(p1+1,i-1);
                p2=i;
                break;
            }
        }
        if(str[p2]=='[')
        {
            int R = rr[p2];
            int tt1,tt2;
            int pp1,pp2;
            for(int i=R+2;i<=r;i++)
            {
                if(str[i]=='x')
                {
                    tt1=cal(R+2,i-1);
                    pp1=i;
                }
                if(str[i]=='['||str[i]==']')
                {
                    tt2=cal(pp1+1,i-1);
                    pp2=i;
                    break;
                }
            }
            int o1 = t1,o2=tt1;
            int hh = a+t1-1;
            for(int j=b;j<=d;j++) change(hh,j,0);
            solve(a,b,c,d-o2+1,pos2+3,R);
            solve(a+o1-1,b,c,d,R+2,r-1);
            return ;
        }
        else
        {
            int tt1,tt2;
            int pp1,pp2;
            for(int i=p2+1;i<=r;i++)
            {
                if(str[i]=='x')
                {
                    tt1=cal(p2+1,i-1);
                    pp1=i;
                }
                if(str[i]=='['||str[i]==']')
                {
                    tt2=cal(pp1+1,i-1);
                    pp2=i;
                    break;
                }
            }
            int o1 = t1,o2=tt1;
            int hh = a+t1-1;
            for(int j=b;j<=d;j++) change(hh,j,0);
            solve(a,b,c,d-o2+1,pos2+3,p2-1);
            solve(a+o1-1,b,c,d,p2+1,r-1);
            return ;
        }
    }
    else
    {
        int t1,t2;
        int p1,p2;
        for(int i=pos2+3;i<=r;i++)
        {
            if(str[i]=='x')
            {
                t1=cal(pos2+3,i-1);
                p1=i;
            }
            if(str[i]=='['||str[i]==',')
            {
                t2=cal(p1+1,i-1);
                p2=i;
                break;
            }
        }
        if(str[p2]=='[')
        {
            int R = rr[p2];
            int tt1,tt2;
            int pp1,pp2;
            for(int i=R+2;i<=r;i++)
            {
                if(str[i]=='x')
                {
                    tt1=cal(R+2,i-1);
                    pp1=i;
                }
                if(str[i]=='['||str[i]==']')
                {
                    tt2=cal(pp1+1,i-1);
                    pp2=i;
                    break;
                }
            }
            int o1 = t2,o2=tt2;
            int hh = b+t2-1;
            for(int i=a;i<=c;i++) change(i,hh,1);
            solve(a,b,c,d-o2+1,pos2+3,R);
            solve(a,b+o1-1,c,d,R+2,r-1);
            return ;
        }
        else
        {
            int tt1,tt2;
            int pp1,pp2;
            for(int i=p2+1;i<=r;i++)
            {
                if(str[i]=='x')
                {
                    tt1=cal(p2+1,i-1);
                    pp1=i;
                }
                if(str[i]=='['||str[i]==']')
                {
                    tt2=cal(pp1+1,i-1);
                    pp2=i;
                    break;
                }
            }
            int o1 = t2,o2=tt2;
            int hh = b+t2-1;
            for(int i=a;i<=c;i++) change(i,hh,1);
            solve(a,b,c,d-o2+1,pos2+3,p2-1);
            solve(a,b+o1-1,c,d,p2+1,r-1);
            return ;
        }
    }
}
int s[100005];
int top=0;
int main()
{

    //freopen("H.in","r",stdin);
    int n,m;
    while(scanf("%s",str)!=EOF)
    {
        int len=strlen(str);
        n=0,m=0;
        top=0;
        int pos1,pos2;
        for(int i=0;i<len;i++)
        {
            if(str[i]=='x')
            {
                n=cal(0,i-1);
                pos1=i;
            }
            if(str[i]=='[')
            {
                m=cal(pos1+1,i-1);
                pos2=i;
                break;
            }
        }
       // dbg2(n,m);
        for(int i=0;i<n;i++) for(int j=0;j<m;j++) ans[i][j]=' ';
        for(int i=0;i<m;i++) ans[0][i]='-';
        ans[0][0]='+';
        ans[0][m-1]='+';
        for(int i=0;i<m;i++) ans[n-1][i]='-';
        for(int i=1;i<n-1;i++) ans[i][0]='|';
        for(int i=1;i<n-1;i++) ans[i][m-1]='|';
        ans[n-1][0]='+';
        ans[n-1][m-1]='+';
        for(int i=0;i<len;i++) rr[i]=-1;
        for(int i=0;i<len;i++)
        {
            if(str[i]=='[') s[++top]=i;
            else if(str[i]==']')
            {
                int tp=s[top];
                --top;
                rr[tp]=i;
            }
        }
       // ok;
        solve(0,0,n-1,m-1,0,len-1);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                printf("%c",ans[i][j]);
            }
            puts("");
        }
        puts("");
    }

    return 0;

}


信息

递交者
类型
递交
语言
C++
递交时间
2019-06-09 23:16:02
评测时间
2019-06-09 23:16:02
评测机
分数
10
总耗时
21ms
峰值内存
724.0 KiB