锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
//640827 2009-05-18 17:58:06 Accepted 1721 C++ 1.6K 0'00.00" 1212K asliyunsong
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()

{
int tc,T;
int j,len;
string str,names;
string pep[] =
{"a","Anne","Bob","Karin","Charly","Dave","Edward","Frank"};
scanf("%d",&T);
getchar();
for(tc = 1; tc <= T;tc ++)
{
map<string,int> M;
getline(cin,str);
str += " ";
len = str.length();
names = "";
for(j = 0;j<len;j++)
{
if(str[j] == ' ')
{
M[names] = 1;
names = "";
}
else
names += str[j];
}
int pt1 ,pt2,pt3;
pt1 = pt2 = pt3 = 0;
if(M[pep[1]] == 1)
pt1++;
if(M[pep[2]] == 1)
{
if(M[pep[3]] == 1 && M[pep[5]] == 0 && M[pep[1]] == 1 && M[pep[6]] == 0)
pt2++;
else if(M[pep[3]] == 0 && ( M[pep[5]] == 1 || M[pep[1]] == 0 || M[pep[6]] == 1))
pt3 ++;
}
if(M[pep[3]] == 1)
{
if(M[pep[4]] == 1 )
pt2++;
else if(M[pep[4]] == 0 && M[pep[1]] == 1 )
pt1 ++;
else if(M[pep[4]] == 0 && M[pep[1]] == 0 )
pt3 ++;
}
if(M[pep[4]] == 1)
{
if(M[pep[1]] == 1 )
pt1++;
}
if(M[pep[6]] == 1)
{
if(M[pep[4]] == 0 && M[pep[1]] == 1 )
pt3++;
else
pt1 ++;
}
if(M[pep[7]] == 1)
{
if(M[pep[2]] == 0 && M[pep[1]] == 0 )
pt1 ++;
else if(M[pep[1]] == 1 )
pt2 ++;
}
printf("Scenario #%d:\n",tc);
if(pt1 > pt2 && pt1 > pt3)
{
cout<<"cinema"<<endl;
}
else if(pt2 > pt1 && pt2 > pt3)
{
cout<<"disco"<<endl;
}
else if(pt3 > pt2 && pt3 > pt1)
{
cout<<"cocktail bar"<<endl;
}
else
cout<<"stay at the Hacienda"<<endl;
cout<<endl;
}
return 0;
}
]]>
#include<iostream>
using namespace std;
int main()

{
int i,num[31],p=4,t;
num[1] = 1;
num[2] = 2;
for(i=3;i<=30;i++)
{
num[i] = p + num[i-2];
p *= 2;
}
cin>>t;
while(t--)
{
cin>>i;
cout<<num[i]<<endl;
}
return 0;
}
]]>
//1280467 2009-04-17 18:03:56 Time Limit Exceeded 2275 1000MS 388K 1448 B C++ no way
//1280554 2009-04-17 18:30:28 Accepted 2275 109MS 2416K 665 B C++ no way
#include<iostream>
#include<set>
using namespace std;
int main()

{
int n,a;
char op[5];
while(cin>>n)
{
multiset<int>S;
multiset<int>::iterator p,q;
while(n--)
{
scanf("%s%d",op,&a);
if(op[3] == 'h')
S.insert(a);
else
{
p = S.begin();
if(*p > a)
{
printf("No Element!\n");
continue;
}
p = S.find(a);
if(p!=S.end())
{
printf("%d\n",*p);
S.erase(p);
}
else
{
S.insert(a);
p = q = S.find(a);
p -- ;
printf("%d\n",*p);
S.erase(p);
S.erase(q);
}
}//while(n--)
}
printf("\n");
}
return 0;
}
]]>
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int st[83][83];
int main()

{
int n;
__int64 kk;
while(scanf("%d%I64d",&n,&kk) && n+kk)
{
int i,j,pp;
char str[83],temp[83];
int sh[83],xia[83];
for(i=0;i<n;i++)
{
cin>>pp;
pp--;
sh[i]=pp;//絎琲涓綅緗鎷垮埌pp
xia[pp]=i;
}
getchar();
cin.getline(str,82,'\n');
for(i=0;i<n;i++)
{
j=xia[i];
pp=1;
while(i!=j)
{
st[i][pp++]=j;
j=xia[j];
}
st[i][pp]=st[i][pp+1]=j;
st[i][0]=pp;//寰幆嬈℃暟
}
for(i=0;i<n;i++)
{
if(kk%st[i][0]==0)
pp=st[i][0];
else
{
pp=kk%st[i][0];
pp=st[i][0]-pp;//
}
temp[st[i][pp]]=str[i];
}
temp[n]='\0';
printf("%s\n",temp);
}
return 0;
}
]]>