标签:return name include div color ioi for -- stream
#include<iostream> #include<cstring> using namespace std; string a,c="O",d="I"; int len,aa[10000],N,O,I,maxx; int main(){ cin>>len>>a; for(int i=len-1;i>=0;i--){ if(a[i]==‘N‘){ N+=O; aa[i]=N; } if(a[i]==‘O‘){ O+=I; aa[i]=O; } if(a[i]==‘I‘){ I++; aa[i]=I; } } maxx=N+O; d=a+d; N=0; O=0; I=0; for(int i=len;i>=0;i--){ if(d[i]==‘N‘){ N+=O; aa[i]=N; } if(d[i]==‘O‘){ O+=I; aa[i]=O; } if(d[i]==‘I‘){ I++; aa[i]=I; } } if(N>maxx)maxx=aa[0]; for(int i=len-1;i>=0;i--){ if(a[i]==‘N‘){ a.insert(i+1,c); break; } } N=0; O=0; I=0; for(int i=len;i>=0;i--){ if(a[i]==‘N‘){ N+=O; aa[i]=N; } if(a[i]==‘O‘){ O+=I; aa[i]=O; } if(a[i]==‘I‘){ I++; aa[i]=I; } } if(N>maxx)maxx=aa[0]; cout<<maxx; return 0; }
54 NONOONIONIINIOOONONIIIINNONOINOONNOOIIOIOIOIINONNNIOON
10 ONNINNONNI
标签:return name include div color ioi for -- stream
原文地址:http://www.cnblogs.com/1227xq/p/6011800.html