ural 1155. Troubleduons
1155. Troubleduons
Memory limit: 64 MB
“O, Lord! Those physicists on the Earth have discovered a new elementary particle!”
“No problem, we’ll add another parameter to the General Equation of the Universe.”
Input
Output
Samples
input | output |
---|---|
1 0 1 0 3 1 0 0 |
EF- |
0 1 0 1 2 3 2 2 |
IMPOSSIBLE |
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name) {
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint() {
int Ret = ;
char Ch = ' ';
while(!(Ch >= '' && Ch <= '')) Ch = getchar();
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Ret;
} const int N = , Left[] = {, , , }, Right[] = {, , , };
int Arr[N]; inline void Input() {
Rep(i, ) scanf("%d", Arr+i);
} inline void Create(int x, int y) {
Arr[x]++, Arr[y]++;
printf("%c%c+\n", 'A'+x, 'A'+y);
} inline void Destroy(int x, int y) {
Arr[x]--, Arr[y]--;
printf("%c%c-\n", 'A'+x, 'A'+y);
} inline void Move(int St, int Ed) {
int Tmp;
if(!Ed && St < ) Tmp = ;
else if(!Ed) Tmp = ;
else if(St > ) Tmp = ;
else Tmp = ;
while(Arr[St]) {
if(!Arr[Tmp]) Create(Tmp, Ed);
Destroy(Tmp, St);
}
} inline void Solve() {
int a = , b = ;
Rep(i, ) a += Arr[Left[i]], b += Arr[Right[i]];
if(a != b) puts("IMPOSSIBLE");
else {
Rep(i, )
if(Left[i]) Move(Left[i], );
Rep(i, )
if(Right[i] != ) Move(Right[i], );
while(Arr[]) Destroy(, );
}
} int main() {
#ifndef ONLINE_JUDGE
SetIO("F");
#endif
Input();
Solve();
return ;
}
ural 1155. Troubleduons的更多相关文章
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
- ural 2066. Simple Expression
2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a v ...
- ural 2065. Different Sums
2065. Different Sums Time limit: 1.0 secondMemory limit: 64 MB Alex is a very serious mathematician ...
随机推荐
- Poj 3233 Matrix Power Series(矩阵二分快速幂)
题目链接:http://poj.org/problem?id=3233 解题报告:输入一个边长为n的矩阵A,然后输入一个k,要你求A + A^2 + A^3 + A^4 + A^5.......A^k ...
- 第17章 使用iSCSI服务部署网络存储
章节概述: 本章节将分析SCSI与iSCSI技术结构的不同,了解iSCSI技术的优势.SAN存储网络技术结构以及iSCSI HBA卡的作用. 完整演示部署iSCSI target服务程序的方法流程:创 ...
- 2015-2-10 Linux 知识
1.Linux系统中某个可执行文件属于root并且有setid,当一个普通用户mike运行这个程序时,产生的进程的有效用户和实际用户分别是____? A root mike B root rooy C ...
- 26.打印所有和为S的连续正整数序列[FindContinuousSequencesWithSumS]
[题目] 输入一个正数n,输出所有和为n连续正数序列.例如输入15,由于1+2+3+4+5=4+5+6=7+8=15,所以输出3个连续序列1-5.4-6和7-8. [分析] 这是网易的一道面试题.这道 ...
- Solr5.3.1 SolrJ查询索引结果
通过SolrJ获取Solr检索结果 1.通过SolrParams的方式提交查询参数 SolrClient solr = new HttpSolrClient("http://localhos ...
- C++ 通过WIN32 API 获取逻辑磁盘详细信息
众所周知,在微软的操作系统下编写应用程序,最主要的还是通过windows所提供的api函数来实现各种操作的,这些函数通常是可以直接使用的,只要包含windows.h这个头文件, 下载源文件 今天我们主 ...
- 重温CSS之背景、文本样式
CSS背景样式: 背景色:background-color属性,设置元素的背景色,如:div {background:blue;}--设置所有div元素的背景为蓝色: 背景图像:background- ...
- mybatisforeach循环,传入多个参数
上代码: controller: @RequestMapping(value = "/findPage", method = RequestMethod.POST) @Respon ...
- Light OJ 1253 Misere Nim (尼姆博弈(2))
LightOJ1253 :Misere Nim 时间限制:1000MS 内存限制:32768KByte 64位IO格式:%lld & %llu 描述 Alice and Bob ar ...
- subversion 版本库数据迁移 从一台服务器迁移到另一台新有服务器
[root@NGINX-APACHE-SVN pro]# pwd /var/www/html/svn/pro [root@NGINX-APACHE-SVN pro]# svnadmin dump /v ...