Submission #61949294


Source Code Expand

// LUOGU_RID: 199988910
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,dp[N][3];//RPS
char s[N];
signed main(){
	cin>>n>>s+1;
	for(int i=1;i<=n;i++){
		if(s[i]=='R'){
			dp[i][0]=max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=max(dp[i-1][0],dp[i-1][2])+1;
		}
		if(s[i]=='P'){
			dp[i][2]=max(dp[i-1][0],dp[i-1][1])+1;
			dp[i][1]=max(dp[i-1][0],dp[i-1][2]);
		}
		if(s[i]=='S'){
			dp[i][0]=max(dp[i-1][1],dp[i-1][2])+1;
			dp[i][2]=max(dp[i-1][0],dp[i-1][1]);
		}
	}
	printf("%lld",max({dp[n][0],dp[n][1],dp[n][2]}));
	return 0;
}

Submission Info

Submission Time
Task D - AtCoder Janken 3
User Muyangmiku
Language C++ 17 (gcc 12.2)
Score 400
Code Size 595 Byte
Status AC
Exec Time 6 ms
Memory 8728 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:9:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
    9 |         cin>>n>>s+1;
      |                 ~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt, 02_handmade_30.txt, 02_handmade_31.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3668 KiB
00_sample_01.txt AC 1 ms 3796 KiB
00_sample_02.txt AC 1 ms 3864 KiB
01_random_03.txt AC 6 ms 8476 KiB
01_random_04.txt AC 5 ms 8600 KiB
01_random_05.txt AC 5 ms 8544 KiB
01_random_06.txt AC 5 ms 8600 KiB
01_random_07.txt AC 5 ms 8652 KiB
01_random_08.txt AC 5 ms 8608 KiB
01_random_09.txt AC 5 ms 8528 KiB
01_random_10.txt AC 5 ms 8540 KiB
01_random_11.txt AC 6 ms 8524 KiB
01_random_12.txt AC 5 ms 8544 KiB
01_random_13.txt AC 6 ms 8596 KiB
01_random_14.txt AC 5 ms 8500 KiB
01_random_15.txt AC 5 ms 8668 KiB
01_random_16.txt AC 2 ms 4968 KiB
01_random_17.txt AC 4 ms 6932 KiB
01_random_18.txt AC 5 ms 7936 KiB
01_random_19.txt AC 5 ms 7824 KiB
01_random_20.txt AC 6 ms 8492 KiB
01_random_21.txt AC 2 ms 5500 KiB
01_random_22.txt AC 5 ms 8108 KiB
02_handmade_23.txt AC 1 ms 3664 KiB
02_handmade_24.txt AC 1 ms 3724 KiB
02_handmade_25.txt AC 1 ms 3672 KiB
02_handmade_26.txt AC 5 ms 8648 KiB
02_handmade_27.txt AC 5 ms 8644 KiB
02_handmade_28.txt AC 5 ms 8600 KiB
02_handmade_29.txt AC 5 ms 8544 KiB
02_handmade_30.txt AC 5 ms 8604 KiB
02_handmade_31.txt AC 5 ms 8728 KiB