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 |
---|---|
|
|
|
|
- #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 ...
随机推荐
- java笔记--关于int和byte[]的转换
关于int和byte[]数组的转换 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/3891747.html "谢谢-- 众所 ...
- HNU 12826 Balloons Colors
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12826&courseid=268 #include&l ...
- 疯狂抨击ie6下各种扭曲行为
从开始接触ie6就被它强大的力量给震住了,虽然它很可怕,但是我总归得想方设法把它给扼杀在摇篮外.以下是我在ie6下面碰到的一些扭曲行为,弱弱的把它给干掉!!! 1.浮动下margin翻倍问题(很典型, ...
- 15 day 1代碼
第一题 用堆维护. #include <cstdio> #include <algorithm> #include <queue> int n,i,f[400000 ...
- SSM框架Web程序的流程(Spring SpringMVC Mybatis)
SSM框架的Web程序主要用到了三个技术: Spring:用到了注解和自动装配,就是Spring的两个精髓IOC(反向控制)和 AOP(面向切面编程). SpringMVC:用到了MVC模型,将逻辑代 ...
- Ubuntu14.04server开放rootssh登录权限
刚安装了Ubuntu 14.04 server的虚拟机,普通帐号可以远程登录,但是root不行,输入密码后一直报错: permission denied 最后发现ssh的配置(/etc/ssh/ssh ...
- 使用shadow dom封装web组件
什么是shadow dom? 首先我们先来看看它长什么样子.在HTML5中,我们只用写如下简单的两行代码,就可以通过 <video> 标签来创建一个浏览器自带的视频播放器控件. <v ...
- Windows远程桌面连接如何直接使用剪贴板功能
连接到Windows Server服务器时,通常使用远程桌面连接,那么如果有些时候按照习惯复制本地文件到远程服务器发现无法粘贴怎么办,这个时候稍微设置一下就OK了, 首先重新运行远程桌面连接,在登陆界 ...
- (原创)Python文件与文件系统系列(4)——文件描述字操作
文件描述字(file descriptor,fd)是系统中用来唯一记录当前已经打开的文件的标识号,fd是一个整数. 除了file对象外,Python还提供对fd的操作,对fd的操作更加底层,fd和Py ...
- 【JAVA、C++】LeetCode 007 Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 解题思路:将数字 ...