Submission #3773478
Source Code Expand
#include<iostream> #include<cstring> using namespace std; inline void ini(string& a,string& b) { string t1="",t2="";int la=a.size(),lb=b.size(); for(int i=0;i<la;++i)t1+=a[i]; for(int i=0;i<lb;++i)t2+=b[i]; for(int i=0;i<la;++i)a[la-i-1]=t1[i]; for(int i=0;i<lb;++i)b[lb-i-1]=t2[i]; return; } int Lenn; inline void change(string& a,int t) { a[t]=a[t]=='1'?'0':'1'; return; } inline int One(string a) { int res=0,len=a.size(); for(int i=0;i<len;++i) if(a[i]=='1') res++; return res; } inline void add(string& x) { int X[100002]={0},l=x.size(); for(int i=0;i<l;++i)X[i]=x[i]-48; X[0]+=1; for(int i=0;i<l;++i) if(X[i]>1) { X[i+1]+=X[i]/2,X[i]%=2; if(i==l-1)++l; } for(int i=0;i<l;++i)x[i]=X[i]^48; return; } inline bool comp(string a,string b,int lb) { int la=a.size(); if(la>lb)return true; if(la<lb)return false; for(int i=la-1;i>=0;--i) if(a[i]>b[i])return true; else if(a[i]<b[i])return false; //return true; return false; } inline void suwakow(string& s) { int t=0,l=s.size(); int num[1000002]={0}; for(int i=0;i<l;++i)num[i]=s[i]-48; for(int i=0;i<l;++i) { num[i]+=t;t=0; if(num[i]>1) t=num[i]/2; num[i]%=2; if(t&&i==l-1)++l; } for(int i=0;i<l;++i)s[i]=num[i]^48; return; }int H[1000002]={0}; string h; inline int Add(string a,string b) { int la=a.size(),lb=b.size(); int l=max(la,lb); string h; for(int i=0;i<l;++i) { H[i]=0; if(i<la)H[i]+=a[i]-48; if(i<lb)H[i]+=b[i]-48; //cout<<"a:"<<a[i]<<endl<<"b:"<<b[i]<<endl; //cout<<endl; //cout<<"h:"<<H[i]<<endl<<endl; } //cout<<endl;system("cls"); int t=0; for(int i=0;i<l;++i) { H[i]+=t;t=0; if(H[i]>1) t=H[i]/2,H[i]%=2; if(t&&i==l-1)++l; }h=""; for(int i=0;i<l;++i) { //cout<<"H:"<<H[i]<<" "; h[i]=H[i]+48; //cout<<"h:"<<h[i]<<endl; } return l; } inline int findX(string a,string b) { string X,x=a; int maxx=One(x); //cout<<"x:"<<x<<endl; //cout<<"maxx:"<<maxx<<endl; //cout<<endl;system("cls"); /// int l=Add(a,b); while(!comp(x,h,l)) { add(x); //cout<<"x:"<<x<<endl; //system("cls"); int t=One(x); if(t>maxx) maxx=t,X=x; if(maxx>=Lenn)return Lenn;// //cout<<x<<endl<<endl; } //return X; return maxx; } inline int two2ten(string a) { int res=0; int l=a.size(); for(int i=0;i<l;++i) if(a[i]^48) res+=1<<i; return res; } int findnew(string a,string b) { int l=Add(a,b); bool f=0; int sum=0; for(int i=l-1;i>=0;--i) if(h[i]=='1') { f=1; sum++; } else if(h[i]=='0'&&f&&h[i-1]=='1') { sum+=i; return sum; } return sum; } int main() { ios::sync_with_stdio(false); int n,t;string a,b; cin>>n>>a>>b;ini(a,b);//getchar(); Lenn=max(a.size(),b.size()); //cout<<a<<endl<<b<<endl<<endl; //return 0; while(n--) { string ch;cin>>ch; //cout<<ch<<endl; //system("cls"); if(ch=="Q") { //int x=findX(a,b); //cout<<a<<endl<<b<<endl; //cout<<findX(a,b)<<endl; cout<<findnew(a,b)<<endl; //cout<<two2ten(x)<<endl<<endl; } else if(ch=="A") { cin>>t; change(a,t); }else { cin>>t; change(b,t); } } }
Submission Info
Submission Time | |
---|---|
Task | I - A + B |
User | lsy263 |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 3261 Byte |
Status | RE |
Exec Time | 130 ms |
Memory | 3160 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00-gray1-1.txt, 00-gray1-2.txt, 00-gray1-3.txt, 00-gray1-4.txt, 00-gray1-5.txt, 00-gray1-6.txt, 00-gray1-7.txt, 00-gray2-1.txt, 00-gray2-2.txt, 00-gray2-3.txt, 00-gray2-4.txt, 00-gray2-5.txt, 00-gray2-6.txt, 00-gray2-7.txt, 00-gray3-1.txt, 00-gray3-2.txt, 00-gray3-3.txt, 00-gray3-4.txt, 00-gray3-5.txt, 00-gray3-6.txt, 00-gray3-7.txt, 00-gray4-1.txt, 00-gray4-2.txt, 00-gray4-3.txt, 00-gray4-4.txt, 00-gray4-5.txt, 00-gray4-6.txt, 00-gray4-7.txt, 00-gray5-1.txt, 00-gray5-2.txt, 00-gray5-3.txt, 00-gray5-4.txt, 00-gray5-5.txt, 00-gray5-6.txt, 00-gray5-7.txt, 00-gray6-1.txt, 00-gray6-2.txt, 00-gray6-3.txt, 00-gray6-4.txt, 00-gray6-5.txt, 00-gray6-6.txt, 00-gray6-7.txt, 00-gray7-1.txt, 00-gray7-2.txt, 00-gray7-3.txt, 00-gray7-4.txt, 00-gray7-5.txt, 00-gray7-6.txt, 00-gray7-7.txt, 00-sample1.txt, 50-random00.txt, 50-random01.txt, 50-random02.txt, 50-random03.txt, 50-random04.txt, 50-random05.txt, 50-random06.txt, 50-random07.txt, 50-random08.txt, 50-random09.txt, 50-random10.txt, 50-random11.txt, 50-random12.txt, vsparallel00.txt, vsparallel01.txt, vsparallel02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-gray1-1.txt | WA | 1 ms | 256 KB |
00-gray1-2.txt | WA | 1 ms | 256 KB |
00-gray1-3.txt | WA | 1 ms | 256 KB |
00-gray1-4.txt | WA | 1 ms | 256 KB |
00-gray1-5.txt | WA | 2 ms | 256 KB |
00-gray1-6.txt | WA | 2 ms | 256 KB |
00-gray1-7.txt | WA | 2 ms | 256 KB |
00-gray2-1.txt | WA | 1 ms | 256 KB |
00-gray2-2.txt | WA | 1 ms | 256 KB |
00-gray2-3.txt | WA | 1 ms | 256 KB |
00-gray2-4.txt | WA | 1 ms | 256 KB |
00-gray2-5.txt | WA | 2 ms | 256 KB |
00-gray2-6.txt | WA | 2 ms | 256 KB |
00-gray2-7.txt | WA | 3 ms | 256 KB |
00-gray3-1.txt | WA | 1 ms | 256 KB |
00-gray3-2.txt | WA | 1 ms | 256 KB |
00-gray3-3.txt | WA | 1 ms | 256 KB |
00-gray3-4.txt | WA | 2 ms | 256 KB |
00-gray3-5.txt | WA | 2 ms | 256 KB |
00-gray3-6.txt | WA | 3 ms | 256 KB |
00-gray3-7.txt | WA | 5 ms | 256 KB |
00-gray4-1.txt | WA | 1 ms | 256 KB |
00-gray4-2.txt | WA | 1 ms | 256 KB |
00-gray4-3.txt | WA | 2 ms | 256 KB |
00-gray4-4.txt | WA | 2 ms | 256 KB |
00-gray4-5.txt | WA | 3 ms | 256 KB |
00-gray4-6.txt | WA | 4 ms | 256 KB |
00-gray4-7.txt | WA | 8 ms | 256 KB |
00-gray5-1.txt | WA | 1 ms | 256 KB |
00-gray5-2.txt | WA | 2 ms | 256 KB |
00-gray5-3.txt | WA | 2 ms | 256 KB |
00-gray5-4.txt | WA | 3 ms | 256 KB |
00-gray5-5.txt | WA | 4 ms | 256 KB |
00-gray5-6.txt | WA | 7 ms | 256 KB |
00-gray5-7.txt | WA | 13 ms | 256 KB |
00-gray6-1.txt | WA | 1 ms | 256 KB |
00-gray6-2.txt | WA | 2 ms | 256 KB |
00-gray6-3.txt | WA | 3 ms | 256 KB |
00-gray6-4.txt | WA | 4 ms | 256 KB |
00-gray6-5.txt | WA | 7 ms | 256 KB |
00-gray6-6.txt | WA | 13 ms | 256 KB |
00-gray6-7.txt | WA | 24 ms | 256 KB |
00-gray7-1.txt | WA | 2 ms | 256 KB |
00-gray7-2.txt | WA | 2 ms | 256 KB |
00-gray7-3.txt | WA | 4 ms | 256 KB |
00-gray7-4.txt | WA | 7 ms | 256 KB |
00-gray7-5.txt | WA | 13 ms | 256 KB |
00-gray7-6.txt | WA | 24 ms | 256 KB |
00-gray7-7.txt | WA | 48 ms | 256 KB |
00-sample1.txt | WA | 1 ms | 256 KB |
50-random00.txt | RE | 98 ms | 256 KB |
50-random01.txt | RE | 98 ms | 256 KB |
50-random02.txt | RE | 98 ms | 256 KB |
50-random03.txt | RE | 99 ms | 256 KB |
50-random04.txt | RE | 98 ms | 256 KB |
50-random05.txt | RE | 105 ms | 2848 KB |
50-random06.txt | RE | 106 ms | 2736 KB |
50-random07.txt | RE | 106 ms | 3060 KB |
50-random08.txt | RE | 105 ms | 2612 KB |
50-random09.txt | RE | 107 ms | 3160 KB |
50-random10.txt | RE | 130 ms | 1004 KB |
50-random11.txt | RE | 129 ms | 1004 KB |
50-random12.txt | RE | 130 ms | 1004 KB |
vsparallel00.txt | RE | 105 ms | 3152 KB |
vsparallel01.txt | RE | 110 ms | 3152 KB |
vsparallel02.txt | RE | 106 ms | 3152 KB |