/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 3ms 768.0 KiB
#3 Accepted 3ms 768.0 KiB
#4 Accepted 3ms 796.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 3ms 1.07 MiB
#7 Accepted 5ms 7.766 MiB
#8 Accepted 6ms 7.379 MiB

Code

//SUST_ZadeedBoss_Fanclub
//code_korlei_life_ase
//na_korle_lifeNai

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T> using o_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define int long long
// #define double long double
// #define all(x) x.begin(), x.end()
// #define rall(x) x.rbegin(), x.rend()
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int dp[500005][15];
void solve ()
{

	int n; cin >>n; n++;
	string s; cin >>s; s = "$" + s;
	string t = "$SeriousOJ";
	int m = t.size();
	for (int i=1; i<n; i++)
	{
		for (int j=1; j<m; j++)
		{
			dp[i][j] = dp[i-1][j];
			if (s[i] == t[j])
			{
				dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
			}
		}

	}
	if (dp[n-1][m-1] == m-1) cout <<"YES\n";
	else cout <<"NO\n";

}

signed main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int TCASE = 1;
	cin >> TCASE;

	for (int tcase = 1; tcase <= TCASE; tcase++)
	{
		// cout <<"Case #" <<tcase <<": ";
		solve();
	}

}

Information

Submit By
Type
Submission
Problem
P1147 SeriousOJ Challenge
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 04:55:05
Judged At
2024-12-09 04:55:05
Judged By
Score
100
Total Time
6ms
Peak Memory
7.766 MiB