题目链接:http://contest.felk.cvut.cz/07cerc/
这次组队只A了两题。一题以前做过的,还有一题是简单模拟签到题。感觉最近很累,一直没状态,这次组队由于少了wz小伙伴,更少了动力。
先说说题吧,这种区域赛的英文题真不是一般人读的,英语是个渣。。。
一题三维的BFS,以前在学BFS的时候学长讲过,这次算是原题出来,结果比赛的时候本来以为自己敲得出来的,结果敲了近两小时都没出来。。。只好让Hypo敲了。。。
第三维钥匙的状态用2进制来表示钥匙的有无。。。
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,m;
char mmap[110][110];
int vis[110][110][110];
struct node
{
int x,y,key,step;
};
int is_key(int key,int t)
{
int k=0;
while(t--)
{
k=key%2;
key/=2;
}
return k;
}
int dx[]= {-1,0,1,0};
int dy[]= {0,1,0,-1};
void bfs(int s,int e)
{
int i,j,t;
queue<node>Q;
node now,next;
now.x=s;
now.y=e;
now.key=0;
now.step=0;
Q.push(now);
vis[s][e][0]=1;
while(!Q.empty())
{
now = Q.front();
Q.pop();
if(mmap[now.x][now.y]=='X')
{
cout<<"Escape possible in "<<now.step<<" steps."<<endl;
return;
}
for(i=0; i<4; i++)
{
next.x=now.x+dx[i];
next.y=now.y+dy[i];
next.key=now.key;
if(next.x<0||next.x>=n||next.y<0||next.y>=m||mmap[next.x][next.y]=='#'||vis[next.x][next.y][next.key])
continue;
if(mmap[next.x][next.y]=='b'||mmap[next.x][next.y]=='y'||mmap[next.x][next.y]=='r'||mmap[next.x][next.y]=='g')
{
if(mmap[next.x][next.y]=='b')
t=0;
else if(mmap[next.x][next.y]=='y')
t=1;
else if(mmap[next.x][next.y]=='r')
t=2;
else t=3;
if(is_key(next.key,t+1)==0)
{
next.key+=pow(2,t);
}
next.step=now.step+1;
vis[next.x][next.y][next.key]=1;
Q.push(next);
}
else if(mmap[next.x][next.y]=='B'||mmap[next.x][next.y]=='Y'||mmap[next.x][next.y]=='R'||mmap[next.x][next.y]=='G')
{
if(mmap[next.x][next.y]=='B')
t=0;
else if(mmap[next.x][next.y]=='Y')
t=1;
else if(mmap[next.x][next.y]=='R')
t=2;
else t=3;
if(is_key(next.key,t+1))
{
next.step=now.step+1;
vis[next.x][next.y][next.key]=1;
Q.push(next);
}
}
else
{
next.step=now.step+1;
vis[next.x][next.y][next.key]=1;
Q.push(next);
}
}
}
cout<<"The poor student is trapped!"<<endl;
}
int main()
{
int i,j,si,sj;
//freopen("k.in","r",stdin);
//freopen("k2.out","w",stdout);
while(cin>>n>>m)
{
if(!n&&!m)break;
memset(vis,0,sizeof(vis));
for(i=0; i<n; i++)
cin>>mmap[i];
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
if(mmap[i][j]=='*')
{
si=i;
sj=j;
}
}
bfs(si,sj);
}
return 0;
}
Reaux! Sham! Beaux!
模拟题,不多说,就是剪刀石头布的游戏,各种手残。。。
还是要好好读题,别没注意细节就各种WA。。。
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
char rrr(char gou[],char str[])
{
if(strcmp(gou,"cs")==0)
{
if(strcmp(str,"Kamen")==0)
{
return 'R';
}
else if(strcmp(str,"Nuzky")==0)
{
return 'S';
}
else if(strcmp(str,"Papir")==0)
{
return 'P';
}
}
else if(strcmp(gou,"en")==0)
{
if(strcmp(str,"Rock")==0)
{
return 'R';
}
else if(strcmp(str,"Scissors")==0)
{
return 'S';
}
else if(strcmp(str,"Paper")==0)
{
return 'P';
}
}
else if(strcmp(gou,"fr")==0)
{
if(strcmp(str,"Pierre")==0)
{
return 'R';
}
else if(strcmp(str,"Ciseaux")==0)
{
return 'S';
}
else if(strcmp(str,"Feuille")==0)
{
return 'P';
}
}
else if(strcmp(gou,"de")==0)
{
if(strcmp(str,"Stein")==0)
{
return 'R';
}
else if(strcmp(str,"Schere")==0)
{
return 'S';
}
else if(strcmp(str,"Papier")==0)
{
return 'P';
}
}
else if(strcmp(gou,"hu")==0)
{
if(strcmp(str,"Ko")==0 ||strcmp(str,"Koe")==0)
{
return 'R';
}
else if(strcmp(str,"Ollo")==0 || strcmp(str,"Olloo")==0)
{
return 'S';
}
else if(strcmp(str,"Papir")==0)
{
return 'P';
}
}
else if(strcmp(gou,"it")==0)
{
if(strcmp(str,"Sasso")==0 ||strcmp(str,"Roccia")==0 )
{
return 'R';
}
else if(strcmp(str,"Forbice")==0)
{
return 'S';
}
else if(strcmp(str,"Carta")==0 || strcmp(str,"Rete")==0)
{
return 'P';
}
}
else if(strcmp(gou,"jp")==0)
{
if(strcmp(str,"Guu")==0)
{
return 'R';
}
else if(strcmp(str,"Choki")==0)
{
return 'S';
}
else if(strcmp(str,"Paa")==0)
{
return 'P';
}
}
else if(strcmp(gou,"pl")==0)
{
if(strcmp(str,"Kamien")==0)
{
return 'R';
}
else if(strcmp(str,"Nozyce")==0)
{
return 'S';
}
else if(strcmp(str,"Papier")==0)
{
return 'P';
}
}
else if(strcmp(gou,"es")==0)
{
if(strcmp(str,"Piedra")==0)
{
return 'R';
}
else if(strcmp(str,"Tijera")==0)
{
return 'S';
}
else if(strcmp(str,"Papel")==0)
{
return 'P';
}
}
}
int main()
{
char gou1[5],gou2[5],name1[20],name2[20],str1[10],str2[10];
int i,j,k=1;
//freopen("1","r",stdin);
while(cin>>gou1>>name1)
{
int tf = 0;
if(strcmp(gou1,".")==0)break;
cin>>gou2>>name2;
int s1=0;
int s2=0;
while(cin>>str1)
{
if(strcmp(str1,"-")==0)break;
if(strcmp(str1,".")==0)
{
tf = 1;
break;
}
cin>>str2;
char a1,a2;
a1=rrr(gou1,str1);
a2=rrr(gou2,str2);
if(a1=='R'&&a2=='S')
{
s1++;
}
else if(a1=='R'&&a2=='P')
{
s2++;
}
else if(a1=='S'&&a2=='R')
{
s2++;
}
else if(a1=='S'&&a2=='P')
{
s1++;
}
else if(a1=='P'&&a2=='R')
{
s1++;
}
else if(a1=='P'&&a2=='S')
{
s2++;
}
}
cout<<"Game #"<<k++<<":"<<endl;
cout<<name1<<": "<<s1<<" point";
if(s1!=1)cout<<"s"<<endl;
else cout<<endl;
cout<<name2<<": "<<s2<<" point";
if(s2!=1)cout<<"s"<<endl;
else cout<<endl;
if(s1<s2)
cout<<"WINNER: "<<name2<<endl;
else if(s1>s2)
cout<<"WINNER: "<<name1<<endl;
else cout<<"TIED GAME"<<endl;
cout<<endl;
if (tf)
break;
}
return 0;
}
英语不行,得老老实实的看英语。。。
各种知识点不足,以前的知识点都没有掌握好。。。