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 ...
随机推荐
- Android Activity模拟dialog
Android项目中很多地方,都会弹出一个弹出框.类似于自己定义的alertDialog,比如微信的退出提示,但由于Dialog的限制,可能不能很完美的实现你的想要的功能,所有研究发现他们这种实现其实 ...
- [Unity3D]引擎崩溃、异常、警告、BUG与提示总结及解决方法
1.U3D经常莫名奇妙崩溃. 一般是由于空异常造成的,多多检查自己的引用是否空指针. 2.编码切换警告提示. 警告提示:Some are Mac OS X (UNIX) and some ...
- xcode arc引起的autorelease报错问题
http://blog.csdn.net/xiechengfa/article/details/37971223 自从用上了真苹果,一直升级,现在xcode版本是4.4,或者说是ios5 一直有个问题 ...
- maven最齐全配置pom.xml
0001<project xmlns="http://maven.apache.org/POM/4.0.0"0002 0003xmlns:xsi="http://w ...
- Rotate bitmap by real angle
tl;dr; Use GDI+ SetWorldTransform With WinAPI's SetWorldTransform you can transform the space of dev ...
- 关于DCMTK3.6.0源代码编译的总结
1.DCMTK cmake出来的代码是一样的.MT和MD版本的区别在于DCMTK工程下的每个子工程的代码生成中的MT还是MD,只要修改成为相应的值就可以了. 2.依赖包的选择.依赖包必须与上面中所说的 ...
- jquery.fileupload.js 杂记
通过$your_jq_dom.fileupload({},donf:function...,fail:function..., ...) 得到的只是一个支持上传的控件,当然绑定了各种事件. 传参给ur ...
- Android measure和layout的一点理解
首先,推荐文章,http://blog.csdn.net/hqdoremi/article/details/9980481,http://www.docin.com/p-571954086.html ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib
今天在linux里安装mysql,运行时遇到这样的错误 ERROR 2002 (HY000): Can't connect to local MySQL server through socket ' ...
- IOS多线程(NSOperation,NSOperationQueue)
含义:NSOperation,NSOperationQueue是什么. The NSOperation class is an abstract class you use to encapsulat ...