Submission #6956380


Source Code Expand

Copy
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define vc vector
	#define PB push_back
	#define pr pair<int,int>
	#define MP make_pair
	#define FR first
	#define SE second
	ll qread()
	{
		ll now=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') now=now*10+c-'0',c=getchar();
		return now*f;
	}
	void write(ll num)
	{
		if(num<0) putchar('-'),num=-num;
		if(num>=10) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	void chmax(int &x,ll y){x=(x>y?x:y);}
	void chmin(int &x,ll y){x=(x<y?x:y);}
	const int MOD=998244353;
	ll qpower(ll x,ll e)
	{
		ll ans=1;
		while(e)
		{
			if(e&1) ans=ans*x%MOD;
			x=x*x%MOD;e>>=1; 
		} 
		return ans;
	}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=1e6+10;

	char str[N];
	void main()
	{
		scanf("%s",str+1);int n=strlen(str+1);
		int cnt=0;bool lst=0,one=1;
		for(int i=1;i<=n;i++)
		{
			if(i==1) cnt++;
			else
			{
				 if(one and str[i-1]==str[i]) lst=1,one=0;
				 else
				 {
				 	cnt++;
				 	if(lst) lst=0;
				 	else one=1;
				 }
			} 
		} 
		write(cnt); 
	}
};
int main()
{
//	freopen("z.txt","r",stdin); 
	srand(time(0));
	mine::main();
}

Submission Info

Submission Time
Task A - Dividing a String
User Zory
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1503 Byte
Status
Exec Time 2 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘void mine::main()’:
./Main.cpp:55:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",str+1);int n=strlen(str+1);
                    ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample01.txt, sample02.txt
All 300 / 300 sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 384 KB
in02.txt 1 ms 384 KB
in03.txt 1 ms 384 KB
in04.txt 1 ms 384 KB
in05.txt 1 ms 384 KB
in06.txt 1 ms 384 KB
in07.txt 1 ms 384 KB
in08.txt 2 ms 384 KB
in09.txt 2 ms 384 KB
in10.txt 2 ms 384 KB
in11.txt 1 ms 128 KB
in12.txt 0 ms 128 KB
in13.txt 0 ms 128 KB
in14.txt 1 ms 128 KB
in15.txt 0 ms 128 KB
in16.txt 0 ms 128 KB
in17.txt 1 ms 384 KB
in18.txt 0 ms 128 KB
in19.txt 0 ms 128 KB
sample01.txt 0 ms 128 KB
sample02.txt 0 ms 128 KB