Submission #930975


Source Code Expand

Copy
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string sT;
	cin>>sT;
	int n=sT.length();
	char *sA = new char[n+1];
	memset(sA,'g',n);
	sA[n]='\0';
	int pMax = n/2;
	int pN=0;
	int i=0;
	for (i=0;i<n;i++){
		if (sT[i]=='g'){
			if (pN<pMax){
				sA[i]='p';
				pN++;
			}else{
				break;
			}
		}
	}
	int sAN=0;
	for (i=0;i<n;i++){
		if (sA[i]=='p' && sT[i]=='p'){
		}
		if (sA[i]=='g' && sT[i]=='g'){
		}
		if (sA[i]=='p' && sT[i]=='g'){
			sAN++;
		}
		if (sA[i]=='g' && sT[i]=='p'){
			sAN--;
		}
	}
	cout<<sAN<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - AtCoDeer and Rock-Paper
User reitetsu
Language C++14 (GCC 5.4.1)
Score 0
Code Size 619 Byte
Status

Compile Error

./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:10:17: error: ‘memset’ was not declared in this scope
  memset(sA,'g',n);
                 ^