【20150815 NOIP2015膜你赛】
Jacinth
posted @ 2015年8月16日 16:32
in ZHOJ
, 623 阅读
至今唯一一场做得还比较欢喜的考试QAQ
T1:LBN loves permutation
边上%%%线段树大师吐槽:lbn怎么还不来?
这题sb多打一个“=”号毁一生啊!!!!
于是我就光荣地错了第一个subtask然后42
,联赛千万别脑抽,联赛千万别脑抽,联赛千万别脑抽
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
char s[200];
int ls,n,tot;
int ans[150];
bool f[150];
bool ff;
void Print()
{
for (int i=1;i<=tot;++i) printf("%d ",ans[i]);
puts("");
return;
}
void BFS(int xx,int yy)
{
int tmp;
if (xx>=ls)
{
if (f[yy])
{
if (yy!=0) ans[++tot]=yy;
Print(),ff=1;
}
return;
}
if (ff) return;
if (yy!=0)
{
tmp=yy*10+s[xx]-'0';
if (f[tmp])
{
f[tmp]=0;
ans[++tot]=tmp;
BFS(xx+1,0);
tot--;
f[tmp]=1;
}
}
tmp=s[xx]-'0';
if (f[yy])
{
if (yy!=0) f[yy]=0,ans[++tot]=yy;
BFS(xx+1,tmp);
if (yy != 0) tot--;
f[yy]=1;
}
return;
}
int main()
{
freopen("pmt.in","r",stdin); freopen("pmt.out","w",stdout);
while (cin.getline(s,150))
{
ls=strlen(s);
if (ls<=9)
{
for (int i=0;i<ls;++i)
printf("%c ",s[i]);
puts("");
continue;
}
ff=0;
n=(ls-9)/2+9;
memset(f,0,sizeof(f));
tot=0;
memset(ans,0,sizeof(ans));
for (int i=0;i<=n;++i) f[i]=1;
BFS(0,0);
}
fclose(stdin); fclose(stdout);
return 0;
}
应该能对了↑
T2:LBN loves chess
试了一个样例,就本能地只管大胆假设,绝不小心求证
事实证明竟然是对的!!!!窝的RP是都用在这上了吗QAQ
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#define INF 1000000100
using namespace std;
int n,xx,yy,tx,ty,maxx,maxy;
int x[1010],y[1010];
#define gch getchar
char C_get;
void read(int &x)
{
for(x=0,C_get=gch();(C_get<'0'||C_get>'9')&&C_get!='-'&&C_get!='+';C_get=gch());
if(C_get=='-')
for(C_get=gch();C_get>='0'&&C_get<='9';C_get=gch())x=x*10-C_get+'0';
else
{
if(C_get=='+')C_get=gch();
for(;C_get>='0'&&C_get<='9';C_get=gch())x=x*10+C_get-'0';
}
}
int main()
{
freopen("chess.in","r",stdin); freopen("chess.out","w",stdout);
while (scanf("%d",&n)!=EOF)
{
maxx=INF,maxy=INF;
for (int i=1;i<=n;++i)
{
read(x[i]),read(y[i]);
if (x[i]<maxx) maxx=x[i];
if (y[i]<maxy) maxy=y[i];
}
xx=maxx/3;
yy=maxy/3;
tx=maxx%3;
ty=maxx%3;
if (tx==2) xx++;
if (xx<=yy) puts("orzLYD");
else puts("orzLBN");
}
fclose(stdin); fclose(stdout);
return 0;
}
哎本来不应该给某些人看代码的。。←_←
T3:LBN loves game
SG函数没弄好怪我咯,0分爽是爽的
T4:LBN loves艹题
高能,看完题目和数据果断骗了19分
骗分程序
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#define INF 1000000100
using namespace std;
int n,k;
#define gch getchar
char C_get;
void read(int &x)
{
for(x=0,C_get=gch();(C_get<'0'||C_get>'9')&&C_get!='-'&&C_get!='+';C_get=gch());
if(C_get=='-')
for(C_get=gch();C_get>='0'&&C_get<='9';C_get=gch())x=x*10-C_get+'0';
else
{
if(C_get=='+')C_get=gch();
for(;C_get>='0'&&C_get<='9';C_get=gch())x=x*10+C_get-'0';
}
}
int main()
{
freopen("caoti.in","r",stdin); freopen("caoti.out","w",stdout);
while (scanf("%d%d",&n,&k)!=EOF)
{
if (k>(n*(n+1)/2))
{
printf("%d\n",n*(n+1)/2);
puts("0");
}
if (k==0)
{
printf("%d\n",n);
printf("%d\n",n-1);
for (int i=1;i<n;++i) printf("%d ",i);
puts("");
}
}
fclose(stdin); fclose(stdout);
return 0;
}
获得成就:首次rank 2
评论 (0)