/ tabris /

记录详情

Accepted

/in/foo.cc: In function 'void solve(int, int, int, int, int, int)':
/in/foo.cc:118:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                     ^~~
/in/foo.cc:119:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:150:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                     ^~~
/in/foo.cc:151:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:93:16: warning: variable 't2' set but not used [-Wunused-but-set-variable]
         int t1,t2;
                ^~
/in/foo.cc:207:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                 ^~~
/in/foo.cc:208:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:238:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable]
             int tt1,tt2;
                 ^~~
/in/foo.cc:239:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable]
             int pp1,pp2;
                     ^~~
/in/foo.cc:182:13: warning: variable 't1' set but not used [-Wunused-but-set-variable]
         int t1,t2;
             ^~
/in/foo.cc:69:9: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     int x,y;
         ^
/in/foo.cc:69: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:283: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:94:16: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int p1,p2;
                ^~
/in/foo.cc:183:16: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int p1,p2;
                ^~
/in/foo.cc:263: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:249:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     tt2=cal(pp1+1,i-1);
                         ~~~^~~~~~~~~~~
/in/foo.cc:232: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:218:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     tt2=cal(pp1+1,i-1);
                         ~~~^~~~~~~~~~~
/in/foo.cc:230:23: warning: 't2' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int hh = b+t2-1;
                      ~^~~
/in/foo.cc:193:23: warning: 'p1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 t2=cal(p1+1,i-1);
                    ~~~^~~~~~~~~~
/in/foo.cc:175:24: warning: 'tt1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c-o2+1,d,pos2+3,p2-1);
                       ~^~~
/in/foo.cc:144:24: warning: 'tt1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             solve(a,b,c-o2+1,d,pos2+3,R);
                       ~^~~
/in/foo.cc:173:23: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int hh = a+t1-1;
                      ~^~~
/in/foo.cc:184: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:293:22: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 m=cal(pos1+1,i-1);
                   ~~~^~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 2ms 768.0 KiB
#2 Accepted 3ms 716.0 KiB
#3 Accepted 2ms 528.0 KiB
#4 Accepted 3ms 720.0 KiB
#5 Accepted 2ms 344.0 KiB
#6 Accepted 2ms 604.0 KiB
#7 Accepted 1ms 340.0 KiB
#8 Accepted 1ms 604.0 KiB
#9 Accepted 2ms 472.0 KiB
#10 Accepted 1ms 476.0 KiB

代码

#include<stdio.h>
#include<string.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<time.h>
#include<math.h>
using namespace std;

#define ok cout<<"OK"<<endl;
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl;
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl;
#define print(a,n) for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
#define pb push_back
#define Fi first
#define Se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

const double eps = 1e-8;
const double PI = acos(-1.0);
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;



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(i==r)
        {
            y=cal(pos1+1,i);
            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(i==r)
            {
                t2=cal(p1+1,i);
                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;
                }
                if(i==r)
                {
                    tt2=cal(pp1+1,i);
                    pp2=i;
                    break;
                }
            }
         //   dbg2(tt1,tt2);
            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-o2+1,d,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;
                }
                if(i==r)
                {
                    tt2=cal(pp1+1,i);
                    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-o2+1,d,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(i==r)
            {
                t2=cal(p1+1,i);
                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;
                }
                if(i==r)
                {
                    tt2=cal(pp1+1,i);
                    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;
                }
                if(i==r)
                {
                    tt2=cal(pp1+1,i);
                    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.out","w",stdout);
    int flag=0;
    int n,m;
    while(scanf("%s",str)!=EOF)
    {
        if(flag) puts("");
        flag=1;
        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;
            }
            if(i==len-1)
            {
                 m=cal(pos1+1,i);
                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("");
        }
      //  break;
    }

    return 0;

}


信息

递交者
类型
递交
语言
C++
递交时间
2019-06-10 12:30:54
评测时间
2019-06-10 12:30:54
评测机
分数
100
总耗时
23ms
峰值内存
768.0 KiB