fakehandle's blog

By fakehandle, history, 4 years ago, In English

Hi everyone In contest This Question the solution i wrote . But now i am not able to find the logical mistake please help me to find logical mistake.

thanks in advance here is code

...
#include<iostream>
using namespace std;
#define ll long long int
int main(){
	ll t ;
	cin>>t;
	while(t--){
		ll n ,k;
		cin>>n>>k;
		string s;
		cin>>s;
		ll lastX=-1,lastS=-1;
		ll count=0;
		ll last=-1,i;
		for(i=0;i<n;i++){
			if(s[i]=='*'){
				s[i]='x';
				lastX=i;
				count++;
				break;
			}
		}
		for(i=n-1;i>=0;i--){
			if(s[i]=='*'){
				last=i;
				count++;
				s[i]='x';
				break;
			}
		}
		if(last==-1 || last &mdash; lastX<=k){
			cout<<count<<endl;
		}
		else{
			for(i=0;i<n;i++){
				if(s[i]=='*'){
					if(i-lastX<k){
						lastS=i;
					}
					else if((i-lastX==k))
					{
						s[i]='x';
						lastX=i;
						lastS=-1;
						count++;
					}
					else{
						s[lastS]='x';
						lastX=lastS;
						lastS=-1;
						count++;
					}
				}
			}
			if(last-lastX>k&&lastS!=-1){
				count++;
			}
			cout<<count<<endl;
		}
	}
}
...

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By fakehandle, history, 4 years ago, In English

Hi Everyone

I gave a contest in atcoder but i stuck in these question please help me to solve this question.

https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_e

https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_f

Thank you in advance

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By fakehandle, history, 4 years ago, In English

Can any one explain the solution of atcoder task F . The editorial is in Japanese language and i am not able to understand it. Please help me to solve this question.

The contest is already finished.

Thanks in advance.

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it