Section 1.4 The Clocks
0 0 虽然不知不觉做到了Section 1.4了,但是都没有把做题的想法和代码发到这里… 本来今天想从Section 1.2补起来然后发现之前做的题都忘了…(Name That Number那道题是今年3月20日做的,记得才怪呢。)
做Clocks这道题可谓一波三折。题目很好懂,我也很自然地想到了广搜的算法——第三点数据就超时!加了优化,第六点又超时。没辙了,参考网上题解:(1)转的先后没有关系;(2)转4次等于没转。于是只要穷举T T。
唯一让人欣慰的就是确定穷举算法之后一下子就写对了,从头写到尾都没再修改。提交全对的时候已经是Submission #8了。
tt数组是各种转法,t数组用于0、1、2、3穷举,
program clock3;
const tt:array[..,..] of word=((,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,),(,,,,,,,,));
var q_or,q_now:array[..] of word;
t,ans:array[..] of word;
i,j,k:integer;
ansn,ansnt,ttt:integer;
flag:boolean;
ans_out:array[..] of word;
begin
assign(input,'clocks.in');reset(input);
assign(output,'clocks.out');rewrite(output);
for i:= to do
begin
for j:= to do
read(q_or[*(i-)+j]);
readln;
end;
ansn:=;
t[]:=;
while t[]<> do
begin
q_now:=q_or;
for i:= to do
for j:= to t[i] do
for k:= to do
begin
if tt[k,i]= then q_now[k]:=(q_now[k]+) mod +;
end;
flag:=true;
for i:= to do
if q_now[i]<> then flag:=false;
if flag then
begin
ansnt:=;
for i:= to do
ansnt:=ansnt+t[i];
if ansnt<=ansn then
begin
ansn:=ansnt;
ans:=t;
end;
end;
t[]:=t[]+;
i:=;
while t[i]= do
begin
t[i]:=;
t[i+]:=t[i+]+;
inc(i);
end;
end;
//writeln(ansn);
ttt:=;
for i:= to do
for j:= to ans[i] do
begin
inc(ttt);
ans_out[ttt]:=i;
end;
for i:= to ttt- do
write(ans_out[i],' ');
writeln(ans_out[ttt]);
close(input);close(output);
end.
Clocks
Section 1.4 The Clocks的更多相关文章
- keil MDK error: L6236E: No section matches selector - no section 错误
今天板子刚到,新建的第一个工程就报错了. .\Objects\cse.sct(7): error: L6236E: No section matches selector - no section t ...
- 【代码笔记】iOS-一个tableView,两个section
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- gcc/linux内核中likely、unlikely和__attribute__(section(""))属性
查看linux内核源码,你会发现有很多if (likely(""))...及if (unlikely(""))...语句,这些语句其实是编译器的一种优化方式,具 ...
- <section> 标签
最近正在学习html5,刚接触html5,感觉有点不适应,因为有一些标签改变了,特别是div, section article这三个标签,查了一些资料,也试着用html5和css3布局网页,稍微有点头 ...
- [ASP.NET MVC 小牛之路]12 - Section、Partial View 和 Child Action
概括的讲,View中的内容可以分为静态和动态两部分.静态内容一般是html元素,而动态内容指的是在应用程序运行的时候动态创建的内容.给View添加动态内容的方式可归纳为下面几种: Inline cod ...
- $\LaTeX$笔记:Section 编号方式(数字、字母、罗马)&计数器计数形式修改
$\LaTeX$系列根目录: Latex学习笔记-序 IEEE模板中Section的编号是罗马数字,要是改投其他刊物的话可能得用阿拉伯数字,所以可以在导言部分做如下修改(放在导言区宏包调用之后): \ ...
- [DOM Event Learning] Section 4 事件分发和DOM事件流
[DOM Event Learning] Section 4 事件分发和DOM事件流 事件分发机制: event dispatch mechanism. 事件流(event flow)描述了事件对象在 ...
- [DOM Event Learning] Section 3 jQuery事件处理基础 on(), off()和one()方法使用
[DOM Event Learning] Section 3 jQuery事件处理基础 on(),off()和one()方法使用 jQuery提供了简单的方法来向选择器(对应页面上的元素)绑定事件 ...
- [DOM Event Learning] Section 2 概念梳理 什么是事件 DOM Event
[DOM Event Learning] Section 2 概念梳理 什么是事件 DOM Event 事件 事件(Event)是用来通知代码,一些有趣的事情发生了. 每一个Event都会被一个E ...
随机推荐
- DOM节点操作
请尊重知识,请尊重原创 更多资料参考请见 http://www.cezuwang.com/listFilm?page=1&areaId=906&filmTypeId=1 一.创建节 ...
- 在map中根据value获取key
原文:http://blog.csdn.net/mexican_jacky/article/details/51789548 //根据map的value获取map的key private static ...
- Android监听Button和ImageButton控件的点击事件
一.onClick事件 Button和ImageButton都有一个onClick事件,通过自身的.setOnClickListener(OnClickListener)方法添加点击事件 所有的控件都 ...
- python操作mongodb之二聚合查询
#聚合查询 from pymongo import MongoClient db = MongoClient('mongodb://10.0.0.9:27017/').aggregation_exam ...
- Python核心编程-基础
python编码风格指南:www.Python.org/doc/essays/styleguide.htmlwww.Python.org/dev/peps/pep-0007/www.Python.or ...
- html list <==> unformatted list
两者的区别很大不得不擦呢,任何两个东西的差别都很大,不得混淆.---一个有ul/ol的选择,一个没有
- 比对工具之 BWA 使用方法
BWA算法简介: BWA-bactrack BWA-SW BWA-MEM BWA安装: # installing BWA .tar.bz2 -C /opt/biosoft/ cd /opt/bioso ...
- 修复 SQLite 数据库文件
目 录 第1章 说明 1 1 下载SQLite Tools 1 2 运行 2 第1章 说明 笔者编写的一个程序,无法往 SQLite 数据库文件里写数据.使用SQLiteSpy打开该 ...
- Google V8扩展利器发布:v8-native-binding-generator
用C++扩展Google V8很简单,但是类比较多时还是很烦的.前段时间开发cantk-runtime-v8时,我写了一个代码产生器v8-native-binding-generator,让扩展Goo ...
- js中tagName和nodeName
DOM里常见的三种节点类型(总共有12种,如docment):元素节点,属性节点以及文本节点,例如<h2 class="title">head</h2>,其 ...