Submission #97768


Source Code Expand

Copy
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<string.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<iostream>
#include<sstream>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n-1; i >= 0; i--)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y);
#define mins(x,y) x = min(x,y);
#define pb push_back
#define snuke srand((unsigned)clock()+(unsigned)time(NULL))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

const int MX = 100005, INF = 1000000000, mod = 1000000009;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-9;
const int dx[4] = {-1,0,1,0}, dy[4] = {0,-1,0,1}; //<^>v

bool dp[MX][MX];
int d[MX];

int main(){
	string s;
	int n, r;
	cin >> s;
	n = s.size();
	
	rep(i,n+1){
		dp[i][i] = true;
	}
	
	for(int i = 3; i <= n; i+=3){
		rep(l,n){
			r = l+i;
			if(r > n) break;
			if(s[l] == 'i' && s[r-1] == 'i'){
				for(int j = l+1; j < r-1; j++){
					if(s[j] == 'w' && dp[l+1][j] && dp[j+1][r-1]) dp[l][r] = true;
				}
			}
		}
	}
	
	//rep(i,n){printf("%c",s[i]); for(int j = i; j <= n; j++)printf(" %d",dp[i][j]); puts("");}
	
	rep(i,n){
		d[i+1] = max(d[i+1],d[i]);
		for(int j = i+3; j <= n; j+=3){
			if(dp[i][j]) d[j] = max(d[j],d[i]+(j-i)/3);
		}
	}
	
	cout << d[n] << endl;
	
	return 0;
}




Submission Info

Submission Time
Task I - イウィ
User snuke
Language C++ (G++ 4.6.4)
Score 0
Code Size 1647 Byte
Status CE

Compile Error

/tmp/cc0KK0Cr.o: In function `_GLOBAL__sub_I_dp':
Main.cpp:(.text.startup+0x2e5): relocation truncated to fit: R_X86_64_32 against `.bss'
Main.cpp:(.text.startup+0x2f4): relocation truncated to fit: R_X86_64_32 against `.bss'
collect2: ld returned 1 exit status