Submission #1838131


Source Code Expand

#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

string s;
int g,p;
int w,l;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>s;
	REP(i,s.size()) {
		int flg=0;
		if(s[i]=='p') {
			if(g-p>=1) p++,flg=1;
			else g++,l++;
		}
		else {
			if(g-p>=1) p++,w++,flg=1;
			else g++;
		}
	}
	cout<<w-l<<endl;

	return 0;
}

Submission Info

Submission Time
Task D - AtCoDeer and Rock-Paper
User moko_freedom
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1182 Byte
Status AC
Exec Time 2 ms
Memory 512 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 0_000.txt, 0_001.txt
All 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 AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
1_002.txt AC 2 ms 512 KB
1_003.txt AC 1 ms 384 KB
1_004.txt AC 2 ms 512 KB
1_005.txt AC 1 ms 384 KB
1_006.txt AC 2 ms 512 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 2 ms 512 KB
1_009.txt AC 2 ms 512 KB
1_010.txt AC 2 ms 512 KB
1_011.txt AC 2 ms 384 KB
1_012.txt AC 2 ms 512 KB
1_013.txt AC 1 ms 256 KB
1_014.txt AC 2 ms 512 KB
1_015.txt AC 2 ms 384 KB
1_016.txt AC 2 ms 512 KB
1_017.txt AC 2 ms 384 KB
1_018.txt AC 2 ms 512 KB
1_019.txt AC 1 ms 256 KB
1_020.txt AC 2 ms 512 KB
1_021.txt AC 2 ms 384 KB
1_022.txt AC 2 ms 512 KB
1_023.txt AC 2 ms 384 KB
1_024.txt AC 2 ms 512 KB