博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforce 8A-8C
阅读量:4661 次
发布时间:2019-06-09

本文共 2248 字,大约阅读时间需要 7 分钟。

8A用string.find即可,我比较sb的以为string.rfind()和reversestring.find()是一样的,怎么都过不去,被打击透了。

8B开始想的太简单,以为就判断终点是否在中途访问过即可。lur这种情况明显不符合,然后改成bfs,好久没写竟然忘记标记以访问过,搞的mle咯,想了半天才记起来这点...

8C 弱鸡又见dp,无从下手,看了看别人的代码,都说是状态dp,然后拿东西顺序无关,这得好好理解下咯。照例贴大牛代码琢磨...

#include
#include
using namespace std;int main(){ string ostr,str1,str2; bool ff=false,bf=false; cin>>ostr>>str1>>str2; unsigned int s; if((s=ostr.find(str1))!=string::npos&&ostr.rfind(str2)>(s+str1.length()-1)) ff=true; unsigned int ss; string bostr(ostr.rbegin(),ostr.rend()); if((s=bostr.find(str1))!=string::npos&&bostr.find(str2,s+str1.length())!=-1) bf=true; if(ff&&bf) cout<<"both"<
#include
#include
using namespace std;int robotmap[201][201];int main(){ char str[110]={
0}; cin>>str; int lc=0,rc=0,uc=0,dc=0; int x=100,y=100; for(int i=0;i
>deq; deq.push_back(make_pair(xy(100,100),0)); pair
var; int tx,ty; while(!deq.empty()) { var=deq.front(); if(var.first.x==x&&var.first.y==y&&var.second
0&&robotmap[tx-1][ty]==1) deq.push_back(make_pair(xy(tx-1,ty),var.second+1)),robotmap[tx-1][ty]=2; if(tx<200&&robotmap[tx+1][ty]==1) deq.push_back(make_pair(xy(tx+1,ty),var.second+1)),robotmap[tx+1][ty]=2; if(ty>0&&robotmap[tx][ty-1]==1) deq.push_back(make_pair(xy(tx,ty-1),var.second+1)),robotmap[tx][ty-1]=2; if(ty<200&&robotmap[tx][ty+1]==1) deq.push_back(make_pair(xy(tx,ty+1),var.second+1)),robotmap[tx][ty+1]=2; } cout<<"OK"<
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long#define oo 1000000007#define pi acos(-1.0)#define MAXN 24using namespace std; int girl[2],objects[MAXN][2],dp[1<
<
dp[p]+temp) dp[t]=dp[p]+temp,pre[t]=p; for (x=i+1;x
dp[p]+temp) dp[t]=dp[p]+temp,pre[t]=p; } break; //关键 } x=goal; printf("%d\n",dp[x]); while (x) { printf("0 "); t=pre[x]; for (i=0;i

 

转载于:https://www.cnblogs.com/cavehubiao/p/3574841.html

你可能感兴趣的文章