Submission #17517234


Source Code Expand

Copy
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;

int main() {
	string s; cin >> s;
	int N = s.size(), dp[301][301] = {};
	for (int d = 3; d <= N; d++) for (int b = 0; b + d <= N; b++) {
		int e = b + d;
		for (int k = b + 1; k < e; k++) {
			dp[b][e] = max(dp[b][e], dp[b][k] + dp[k][e]);
			if (s[b] == 'i' && s[k] == 'w' && s[e - 1] == 'i' && dp[b + 1][k] == (k - (b + 1)) 
				&& dp[k + 1][e - 1] == ((e - 1) - (k + 1))) {
				dp[b][e] = e - b;
			}
		}
	}
	cout << dp[0][N] / 3 << endl;

	return 0;
}

Submission Info

Submission Time
Task I - イウィ
User nekosun
Language C++ (GCC 9.2.1)
Score 5
Code Size 556 Byte
Status
Exec Time 22 ms
Memory 3944 KB

Judge Result

Set Name All
Score / Max Score 5 / 5
Status
× 7
Set Name Test Cases
All 00, 01, 02, 03, 04, 90, 91
Case Name Status Exec Time Memory
00 20 ms 3792 KB
01 13 ms 3816 KB
02 20 ms 3928 KB
03 22 ms 3860 KB
04 13 ms 3880 KB
90 3 ms 3808 KB
91 2 ms 3944 KB