|
|
вернуться в форумWhy Output Limit? Or WA#1? I know,that put all program is bad,but i can't find and understand my mistake! Output limit#1: #include<iostream> #include<stdio.h> #include<string> #include<string.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif string m,m2,m3="0",m4="1"; char c; int a,b,d,i,m1[100],h,length,kk=0; cin>>a; const int s=a+1; l1:while(cin.get(c)){ kk++; if(kk==0)goto l2; cin.get(c); while(c==10){ cout<<c; cin.get(c); } cin.putback(c); l2: cin>>m; length=m.length(); b=0; d=0; for(i=0;i<length;i++) if(m[i]=='1'){ m1[b]=i; b++; d=d+1+i; } if(length==a) for(i=0;i<b;i++) if((d-m1[i]-1)%s==0){ m[m1[i]]='0'; cout<<m<<endl; goto l1; } h=0; if(length<a){ if((d+length+1)%s==0){ cout<<m<<'1'<<endl; goto l1; } else if(d%s==0){ cout<<m<<'0'<<endl; goto l1; } else for(i=0;i<length;i++){ if((d+(b-h))%s==0){ m.insert(i,m3); cout<<m<<endl; goto l1; } else if((d+(b-h)+1+i)%s==0){ m.insert(i,m4); cout<<m<<endl; goto l1; } if(m[i]=='1')h++; } } h=0; if(length>a) for(i=0;i<length;i++){ if(m[i]=='1'){ h++; if((d-i-(b-h)-1)%s==0){ m.erase(i,1); cout<<m<<endl; goto l1; } } else if((d-(b-h))%s==0){ m.erase(i,1); cout<<m<<endl; goto l1; } } cout<<m<<endl; } return 0; } But without cin.get(c); while(c==10){ cout<<c; cin.get(c); } cin.putback(c); i have WA#1! WHY???? P.S. Sorry for bad English. |
|
|