Submission #929065


Source Code Expand

Copy
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

char s[N];

int main()
{
	ll n,x=0,y=0,ans=0;
	scanf("%s",s);
	n=strlen(s);
	REP(i,n)
	{
		if (s[i]=='g')
		{
			if (x+1<=y)
			{
				x++;
				ans++;
			}
			else y++;
		}
		else
		{
			if (x+1<=y)
				x++;
			else
			{
				ans--;
				y++;
			}
		}
	}
	printf("%lld\n",ans);
return 0;
}

Submission Info

Submission Time
Task D - AtCoDeer and Rock-Paper
User TerryMcGinnis
Language C++14 (GCC 5.4.1)
Score 300
Code Size 928 Byte
Status
Exec Time 3 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
               ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt
All 300 / 300 0_000.txt, 0_001.txt, 1_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt
Case Name Status Exec Time Memory
0_000.txt 2 ms 256 KB
0_001.txt 2 ms 256 KB
1_002.txt 3 ms 384 KB
1_003.txt 3 ms 256 KB
1_004.txt 3 ms 384 KB
1_005.txt 3 ms 256 KB
1_006.txt 3 ms 384 KB
1_007.txt 2 ms 256 KB
1_008.txt 3 ms 384 KB
1_009.txt 3 ms 384 KB
1_010.txt 3 ms 384 KB
1_011.txt 3 ms 256 KB
1_012.txt 3 ms 384 KB
1_013.txt 2 ms 256 KB
1_014.txt 3 ms 384 KB
1_015.txt 3 ms 256 KB
1_016.txt 3 ms 384 KB
1_017.txt 3 ms 384 KB
1_018.txt 3 ms 384 KB
1_019.txt 2 ms 256 KB
1_020.txt 3 ms 384 KB
1_021.txt 3 ms 384 KB
1_022.txt 3 ms 384 KB
1_023.txt 3 ms 384 KB
1_024.txt 3 ms 384 KB