博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
洛谷9月月赛round2
阅读量:7249 次
发布时间:2019-06-29

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

洛谷9月月赛2

t1

题意:懒得说了

分析:模拟

代码:

program flag;var  a:array[0..51,0..51]of char;  n,i,m,j,x,y,ans,k:longint;begin  assign(input,'flag.in');reset(input);assign(output,'flag.out');rewrite(output);  readln(n,m);  for i:=1 to n do begin   for j:=1 to m do     read(a[i,j]);  readln;  end;  k:=maxlongint;  for i:=1 to n-2 do   for j:=i+2 to n do    begin      ans:=0;      for x:=1 to i do       for y:=1 to m do        if a[x,y]<>'W' then inc(ans);      for x:=i+1 to j-1 do       for y:=1 to m do        if a[x,y]<>'B' then inc(ans);      for x:=j to n do       for y:=1 to m do        if a[x,y]<>'R' then inc(ans);      if ans
View Code

 t2

题意:无向无权图中,有k个点是禁止点,不可经过,与禁止点距离不超过s的点是危险点,可以经过,通过普通点花费为p,通过危险点花费为q,求1到n最小花费。

分析:;将0对所有禁止点,以0为起点建边跑最短路,凡是距离<=s+1的且不是禁止点的点标记为危险点,然后以1为起点跑最短路,花费为各点权值,注意最后一个点不交费,要在输出时减去在该点的花费(有两种情况,终点为危险点或普通点),记得用int64,另外dis初值要设很大。

program run;type  point=^node;   node=record     x:longint; next:point;   end;var  a:array[0..100000]of point;  q:array[0..300000]of longint;  dis,mk:array[0..100000]of int64;  g:array[0..100000]of boolean;  n,m,k,maxs,ppp,qqq,x,y:int64;  i:longint;procedure add(x,y:longint);var p:point;begin  new(p); p^.x:=y; p^.next:=a[x]; a[x]:=p;end;procedure spfa(s:longint);var h,t,x,y,cost:int64; i:longint; p:point;begin  for i:=0 to n do dis[i]:=maxlongint*10000;  for i:=0 to n do g[i]:=false;  h:=0; t:=1; q[1]:=s; g[s]:=true; dis[s]:=0;  while h
=300000 then h:=0; while p<>nil do begin y:=p^.x; if not((s=1)and(mk[y]=2)) then begin if s=0 then cost:=1; if s=1 then if mk[y]=0 then cost:=ppp else cost:=qqq; if dis[x]+cost
=300000 then t:=0; end; end; end; p:=p^.next; end; end;end;begin readln(n,m,k,maxs); readln(ppp,qqq); for i:=1 to k do begin readln(x); mk[x]:=2; add(0,x); end; for i:=1 to m do begin readln(x,y); add(x,y); add(y,x); end; spfa(0); for i:=0 to n do if dis[i]<=maxs+1 then begin if mk[i]<2 then mk[i]:=1; end; spfa(1); if n=1 then writeln(0) else if mk[n]=0 then writeln(int64(dis[n]-ppp)) else writeln(int64(dis[n]-qqq));end.
View Code

 t3

题意:给出一段行走命令,机器人连续执行k次,每走一次放一个标记,求四角被标记的正方形个数。

分析:有一个乱搞方法是走4次找出被标记的个数然后得到k次的,正解懒得写了。

转载于:https://www.cnblogs.com/qtyytq/p/5928798.html

你可能感兴趣的文章
Spring4.1-Application Event
查看>>
Python内置模块(一)
查看>>
利用最新新浪微博API做到桌面程序
查看>>
TRUNC函数的用法
查看>>
gre
查看>>
灵巧还是笨重?利用Textarea从浏览器复制字符到剪贴板
查看>>
CentOS 7.4利用Iptables开启远程访问
查看>>
linux下日志监控分析工具webalizer的安装及使用
查看>>
HTTPS 原理详解
查看>>
[转载] 七龙珠第一部——第073话 必杀恶魔光线
查看>>
Get和Post请求区别
查看>>
开源史上最成功的8个开源产品
查看>>
PHP操作MySQL
查看>>
单臂路由与三层交换机动态配置
查看>>
MyBatis学习总结(六)——调用存储过程
查看>>
Docker命令详解
查看>>
servlet jsp 各种路径获取。。
查看>>
应用系统架构设计
查看>>
【POJ】第二章 简单计算题之课后题
查看>>
MFC建立应用程序启示录(创世纪新篇)
查看>>