Wrong Answer
/in/foo.cc: In function 'void solve(int, int, int, int, int, int)': /in/foo.cc:106:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable] int tt1,tt2; ^~~ /in/foo.cc:107:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable] int pp1,pp2; ^~~ /in/foo.cc:132:21: warning: variable 'tt2' set but not used [-Wunused-but-set-variable] int tt1,tt2; ^~~ /in/foo.cc:133:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable] int pp1,pp2; ^~~ /in/foo.cc:87:16: warning: variable 't2' set but not used [-Wunused-but-set-variable] int t1,t2; ^~ /in/foo.cc:177:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable] int tt1,tt2; ^~~ /in/foo.cc:178:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable] int pp1,pp2; ^~~ /in/foo.cc:202:17: warning: variable 'tt1' set but not used [-Wunused-but-set-variable] int tt1,tt2; ^~~ /in/foo.cc:203:21: warning: variable 'pp2' set but not used [-Wunused-but-set-variable] int pp1,pp2; ^~~ /in/foo.cc:158: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:241: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:103:18: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized] if(str[p2]=='[') ~~~~~~^ /in/foo.cc:159:16: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized] int p1,p2; ^~ /in/foo.cc:221: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:213:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized] tt2=cal(pp1+1,i-1); ~~~^~~~~~~~~~~ /in/foo.cc:196: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:188:28: warning: 'pp1' may be used uninitialized in this function [-Wmaybe-uninitialized] tt2=cal(pp1+1,i-1); ~~~^~~~~~~~~~~ /in/foo.cc:194:23: warning: 't2' may be used uninitialized in this function [-Wmaybe-uninitialized] int hh = b+t2-1; ~^~~ /in/foo.cc:169:23: warning: 'p1' may be used uninitialized in this function [-Wmaybe-uninitialized] t2=cal(p1+1,i-1); ~~~^~~~~~~~~~ /in/foo.cc:151: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:126: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:124:23: warning: 't1' may be used uninitialized in this function [-Wmaybe-uninitialized] int hh = a+t1-1; ~^~~ /in/foo.cc:160: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:251:22: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized] m=cal(pos1+1,i-1); ~~~^~~~~~~~~~~~
代码
#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(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;
}
}
// 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;
}
}
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(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.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;
}
}
// 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:25:32
- 评测时间
- 2019-06-10 12:25:32
- 评测机
- 分数
- 40
- 总耗时
- 25ms
- 峰值内存
- 732.0 KiB