ZHY's Blog

#include < bits/stdc++.h >


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

POJ-2718 Smallest Difference(STL全排列 + 输入流魔改)

发表于 2018-08-11 | 更新于: 2018-08-12 | 分类于 题解 , C++ && STL库 | | 阅读次数: |
字数统计: 602 | 阅读时长 ≈ 3

描述

传送门:Smallest Difference

Given a number of distinct decimal digits, you can form one integer by choosing a non-empty subset of these digits and writing them in some order. The remaining digits can be written down in some order to form a second integer. Unless the resulting integer is 0, the integer may not start with the digit 0.

For example, if you are given the digits 0, 1, 2, 4, 6 and 7, you can write the pair of integers 10 and 2467. Of course, there are many ways to form such pairs of integers: 210 and 764, 204 and 176, etc. The absolute value of the difference between the integers in the last pair is 28, and it turns out that no other pair formed by the rules above can achieve a smaller difference.

阅读全文 »

Aizu-0121 Seven Puzzle(BFS+STL+打表)

发表于 2018-08-10 | 更新于: 2018-08-12 | 分类于 题解 , 简单搜索 | | 阅读次数: |
字数统计: 614 | 阅读时长 ≈ 3

描述

传送门:Aizu-0121 Seven Puzzle

7 パズルは 8 つの正方形のカードとこれらのカードがぴたりと収まる枠で構成されています。それぞれのカードには、互いに区別できるように 0, 1, 2, …, 7 と番号がつけられています。枠には、縦に 2 個、横に 4 個のカードを並べることができます。
7 パズルを始めるときには、まず枠にすべてのカードを入れます。枠のなかで 0 のカードだけは、上下左右に隣接するカードと位置を交換することができます。たとえば、枠の状態が図(a) のときに、0 のカードの右に隣接した、7 のカードと位置を交換すれば、図(b) の状態になります。あるいは、図(a) の状態から 0 のカードの下に隣接した 2 のカードと位置を交換すれば図(c) の状態になります。図(a) の状態で 0 のカードと上下左右に隣接するカードは 7 と 2 のカードだけなので、これ以外の位置の入れ替えは許されません。
ゲームの目的は、カードをきれいに整列して図(d) の状態にすることです。最初の状態を入力とし、カードをきれいに整列するまでに、必要な最小手数を出力するプログラムを作成してください。ただし、入力されたカードの状態からは図(d) の状態に移ることは可能であるとします。
入力データは、1 行に 8 つの数字が空白区切りで与えられます。これらは、最初の状態のカードの並びを表します。例えば、図(a) の数字表現は0 7 3 4 2 5 1 6 に、図(c) は 2 7 3 4 0 5 1 6 となります。

(a) 0 7 3 4 2 5 1 6 の場合
(b) 7 0 3 4 2 5 1 6 の場合

(c) 2 7 3 4 0 5 1 6 の場合

(d) 0 1 2 3 4 5 6 7 (最終状態)

阅读全文 »

Aizu-055 Cheese (BFS分段处理)

发表于 2018-08-09 | 更新于: 2018-09-17 | 分类于 题解 , 简单搜索 | | 阅读次数: |
字数统计: 1,024 | 阅读时长 ≈ 5

描述

传送门:Aizu-055 Cheese

今年も JOI 町のチーズ工場がチーズの生産を始め,ねずみが巣から顔を出した.JOI 町は東西南北に区画整理されていて,各区画は巣,チーズ工場,障害物,空き地のいずれかである.ねずみは巣から出発して全てのチーズ工場を訪れチーズを 1 個ずつ食べる.
この町には,N 個のチーズ工場があり,どの工場も1種類のチーズだけを生産している.チーズの硬さは工場によって異なっており,硬さ 1 から N までのチーズを生産するチーズ工場がちょうど 1 つずつある.
ねずみの最初の体力は 1 であり,チーズを 1 個食べるごとに体力が 1 増える.ただし,ねずみは自分の体力よりも硬いチーズを食べることはできない.
ねずみは,東西南北に隣り合う区画に 1 分で移動することができるが,障害物の区画には入ることができない.チーズ工場をチーズを食べずに通り過ぎることもできる.すべてのチーズを食べ終えるまでにかかる最短時間を求めるプログラムを書け.ただし,ねずみがチーズを食べるのにかかる時間は無視できる.

阅读全文 »

POJ-3617 Best Cow Line (贪心)

发表于 2018-08-08 | 更新于: 2018-08-08 | 分类于 题解 , 基础技巧 | | 阅读次数: |
字数统计: 579 | 阅读时长 ≈ 3

描述

传送门:POJ-3617 Best Cow Line

FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual”Farmer of the Year” competition. In this contest every farmer arranges his cows in a line and herds them past the judges.

The contest organizers adopted a new registration scheme this year: simply register the initial letter of every cow in the order they will appear (i.e., If FJ takes Bessie, Sylvia, and Dora in that order he just registers BSD). After the registration phase ends, every group is judged in increasing lexicographic order according to the string of the initials of the cows’ names.

FJ is very busy this year and has to hurry back to his farm, so he wants to be judged as early as possible. He decides to rearrange his cows, who have already lined up, before registering them.

FJ marks a location for a new line of the competing cows. He then proceeds to marshal the cows from the old line to the new one by repeatedly sending either the first or last cow in the (remainder of the) original line to the end of the new line. When he’s finished, FJ takes his cows for registration in this new order.

Given the initial order of his cows, determine the least lexicographic string of initials he can make this way.

阅读全文 »

POJ-3069 Saruman's Army (贪心)

发表于 2018-08-08 | 更新于: 2018-08-09 | 分类于 题解 , 基础技巧 | | 阅读次数: |
字数统计: 596 | 阅读时长 ≈ 3

描述

传送门:POJ-3069 Saruman's Army

Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and must be carried by some troop in the army (i.e., palantirs are not allowed to “free float” in mid-air). Help Saruman take control of Middle Earth by determining the minimum number of palantirs needed for Saruman to ensure that each of his minions is within R units of some palantir.

阅读全文 »

nowcoder163 A-Fruit Ninja(计算几何+随机算法)

发表于 2018-08-07 | 更新于: 2018-09-17 | 分类于 比赛 , 计算几何 | | 阅读次数: |
字数统计: 565 | 阅读时长 ≈ 3

描述

传送门:A-Fruit Ninja

Fruit Ninja is a juicy action game enjoyed by millions of players around the world, with squishy,
splat and satisfying fruit carnage! Become the ultimate bringer of sweet, tasty destruction with every slash.
Fruit Ninja is a very popular game on cell phones where people can enjoy cutting the fruit by touching the screen.
In this problem, the screen is rectangular, and all the fruits can be considered as a point. A touch is a straight line cutting
thought the whole screen, all the fruits in the line will be cut.
A touch is EXCELLENT if $ \dfrac {M}{N} $ ≥ x, (N is total number of fruits in the screen, M is the number of fruits that cut by the touch, x is a real number.)
Now you are given N fruits position in the screen, you want to know if exist a EXCELLENT touch.

阅读全文 »

nowcoder163 D-Thinking Bear magic(计算几何)

发表于 2018-08-07 | 更新于: 2018-08-07 | 分类于 比赛 , 计算几何 | | 阅读次数: |
字数统计: 744 | 阅读时长 ≈ 4

描述

传送门:D-Thinking Bear magic

In order to become a magical girl, Thinking-Bear are learning magic circle.
He first drew a regular polygon of N sides, and the length of each side is a.
He want to get a regular polygon of N sides, and the polygon area is no more than L.
He doesn’t want to draw a new regular polygon as it takes too much effort.
So he think a good idea, connect the midpoint of each edge and get a new regular polygon of N sides.
How many operations does it need to get the polygon he want?

阅读全文 »

nowcoder163 B-Matrix Multiplication (矩阵快速幂 模板)

发表于 2018-08-06 | 更新于: 2018-08-07 | 分类于 比赛 , 数学 | | 阅读次数: |
字数统计: 759 | 阅读时长 ≈ 5

描述

传送门:B-Matrix Multiplication

In mathematics, matrix multiplication or matrix product is a binary operation that produces a matrix from two matrices with entries in a field, or, more generally, in a ring or even a semiring. The matrix product is designed for representing the composition of linear maps that are represented by matrices. Matrix multiplication is thus a basic tool of linear algebra, and as such has numerous applications in many areas of mathematics, as well as in applied mathematics, physics, and engineering. In more detail, if A is an n x m matrix and B is an m x p matrix, their product AB is an n x p matrix, in which the m entries across a row of A are multiplied with the m emtries down a column of B and summed to produce an entry of AB. When two linear maps are represented by matrices, then the matrix product represents the composition of the two maps.
We can only multiply two matrices if their dimensions are compatible, which means the number of columns in the first matrix is the same as the number of rows in the second matrix.
If A is an n x m matrix and B is an m x p matrix,

the matrix product C = AB is defined to be the n x p matrix

such that

,
for i = 1,2, …, n and j = 1,2, …, p.
Your task is to design a matrix multiplication calculator to multiply two matrices and
display the output. If the matrices cannot be multiplied, display “ERROR”.

阅读全文 »

2018 ACM 国际大学生程序设计竞赛上海大都会赛

发表于 2018-08-05 | 更新于: 2018-08-05 | 分类于 比赛 | | 阅读次数: |
字数统计: 437 | 阅读时长 ≈ 2

关于比赛

传送门:2018 ACM 国际大学生程序设计竞赛上海大都会赛

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛
2018-08-05 12:00:00 至 2018-08-05 17:00:00
时长: 5小时


阅读全文 »

POJ-1979 Red and Black (DFS or BFS 暴力)

发表于 2018-08-04 | 更新于: 2018-08-04 | 分类于 题解 , 简单搜索 | | 阅读次数: |
字数统计: 552 | 阅读时长 ≈ 3

描述

传送门:POJ-1979 Red and Black

There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move only on black tiles.

Write a program to count the number of black tiles which he can reach by repeating the moves described above.

阅读全文 »
123…5
卓华寅

卓华寅

人一我百!人十我万!永不放弃~~~怀着自信的心,去追逐梦想——kuangbin

44 日志
14 分类
25 标签
RSS
Creative Commons
友情链接
  • findBUG.top
  • SWOJ
  • Vjudge
  • 张松超
  • 潘坤
  • 王亚东
  • 何世全
  • 朱成锐
  • 曹雨菲
  • kuangbin
0%
© 2018 卓华寅 | Site words total count: 32.1k
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4