您的位置:首页 > 其它

第一次SRM,纪念

2011-10-13 21:11 225 查看
其实topcoder也是蛮有意思的啊,就刷了题水的

View Code

#include<stdio.h>
#include<vector>
#include<string>
using namespace std;
class RedAndGreen{
public :
int minPaints(string row)
{
int i,j;
int a[55],flag[55];
memset(flag,0,sizeof(flag));
int len=row.length();
int tot=0;
for(i=0;i<len-1;i++)
{
if(row[i]=='G')
for(j=i+1;j<len;j++)
{
if(row[j]=='R'&&flag[j]==0)
{
tot++;
flag[j]=1;break;
}
}
}
return tot;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: