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- EA- AD+ AE- DC- |
0 1 0 1 2 3 2 2 |
IMPOSSIBLE |
1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <deque> 6 #include <vector> 7 #include <queue> 8 #include <iostream> 9 #include <algorithm> 10 #include <map> 11 #include <set> 12 #include <ctime> 13 using namespace std; 14 typedef long long LL; 15 typedef double DB; 16 #define For(i, s, t) for(int i = (s); i <= (t); i++) 17 #define Ford(i, s, t) for(int i = (s); i >= (t); i--) 18 #define Rep(i, t) for(int i = (0); i < (t); i++) 19 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--) 20 #define rep(i, x, t) for(int i = (x); i < (t); i++) 21 #define MIT (2147483647) 22 #define INF (1000000001) 23 #define MLL (1000000000000000001LL) 24 #define sz(x) ((int) (x).size()) 25 #define clr(x, y) memset(x, y, sizeof(x)) 26 #define puf push_front 27 #define pub push_back 28 #define pof pop_front 29 #define pob pop_back 30 #define ft first 31 #define sd second 32 #define mk make_pair 33 inline void SetIO(string Name) { 34 string Input = Name+".in", 35 Output = Name+".out"; 36 freopen(Input.c_str(), "r", stdin), 37 freopen(Output.c_str(), "w", stdout); 38 } 39 40 inline int Getint() { 41 int Ret = 0; 42 char Ch = ' '; 43 while(!(Ch >= '0' && Ch <= '9')) Ch = getchar(); 44 while(Ch >= '0' && Ch <= '9') { 45 Ret = Ret*10+Ch-'0'; 46 Ch = getchar(); 47 } 48 return Ret; 49 } 50 51 const int N = 8, Left[4] = {0, 2, 5, 7}, Right[4] = {1, 3, 4, 6}; 52 int Arr[N]; 53 54 inline void Input() { 55 Rep(i, 8) scanf("%d", Arr+i); 56 } 57 58 inline void Create(int x, int y) { 59 Arr[x]++, Arr[y]++; 60 printf("%c%c+\n", 'A'+x, 'A'+y); 61 } 62 63 inline void Destroy(int x, int y) { 64 Arr[x]--, Arr[y]--; 65 printf("%c%c-\n", 'A'+x, 'A'+y); 66 } 67 68 inline void Move(int St, int Ed) { 69 int Tmp; 70 if(!Ed && St < 4) Tmp = 1; 71 else if(!Ed) Tmp = 4; 72 else if(St > 3) Tmp = 5; 73 else Tmp = 0; 74 while(Arr[St]) { 75 if(!Arr[Tmp]) Create(Tmp, Ed); 76 Destroy(Tmp, St); 77 } 78 } 79 80 inline void Solve() { 81 int a = 0, b = 0; 82 Rep(i, 4) a += Arr[Left[i]], b += Arr[Right[i]]; 83 if(a != b) puts("IMPOSSIBLE"); 84 else { 85 Rep(i, 4) 86 if(Left[i]) Move(Left[i], 0); 87 Rep(i, 4) 88 if(Right[i] != 4) Move(Right[i], 4); 89 while(Arr[0]) Destroy(0, 4); 90 } 91 } 92 93 int main() { 94 #ifndef ONLINE_JUDGE 95 SetIO("F"); 96 #endif 97 Input(); 98 Solve(); 99 return 0; 100 }
View Code
转载于:https://www.cnblogs.com/StupidBoy/p/4902963.html
ural 1155. Troubleduons相关推荐
- Ural 1018 (树形DP+背包+优化)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 题目大意:树枝上间连接着一坨坨苹果(不要在意'坨'),给 ...
- bzoj1814 Ural 1519 Formula 1(插头dp模板题)
1814: Ural 1519 Formula 1 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 924 Solved: 351 [Submit][S ...
- PAT甲级1155 Heap Paths (30 分):[C++题解]堆、堆的遍历、树的遍历、dfs输出路径、完全二叉树建树
文章目录 题目分析 题目链接 题目分析 来源:acwing 分析: 堆首先是完全二叉树,所以先建完全二叉树,由于给定的是层序遍历的数据,所以直接用数组即可,注意数组下标从1开始,这样便满足结点u和左儿 ...
- URAL 1635 Mnemonics and Palindromes
URAL 1635 思路:区间dp+贪心,先n^2处理出每段区间是否是回文串,然后贪心地找每一段1到i的最少分割. 代码: #include<bits/stdc++.h> using na ...
- [代码]ural 1655 Somali Pirates
Abstract ural 1655 Somali Pirates dp Source http://acm.timus.ru/problem.aspx?space=1&num=1655 So ...
- ural 1306. Sequence Median(优先级队列 priority_queue用法)
最近做的ural的题目总是各种错,看了解题报告都是自己没学过的玩意,有点受打击,不过ural的题目质量还是挺好的,多被虐虐有益健康. 这一题要是用数组直接超内存,用优先级队列做,刚接触这个,学习一下优 ...
- 1155: 零起点学算法62——输出矩阵
1155: 零起点学算法62--输出矩阵 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lld Submitted: 997 ...
- DFS水题 URAL 1152 False Mirrors
题目传送门 1 /* 2 题意:一个圈,每个点有怪兽,每一次射击能消灭它左右和自己,剩余的每只怪兽攻击 3 搜索水题:sum记录剩余的攻击总和,tot记录承受的伤害,当伤害超过ans时,结束,算是剪枝 ...
- 【BZOJ1814】Ural 1519 Formula 1 插头DP
[BZOJ1814]Ural 1519 Formula 1 题意:一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数.(n,m<=12) 题解:插头DP板子题,刷板 ...
最新文章
- 使用【python语言】和【typescript】进行冒泡排序
- K8S集群搭建:安装kubeadm集群部署工具
- 2019第十届蓝桥杯C/C++ A组省赛 —— 第四题:迷宫
- c++ 走向高级之日积月累
- CNI portmap插件实现源码分析
- 刘强东宣布向瑞士捐赠160万只口罩及其他大量急需医疗物资
- 风投的钱都从哪里来?
- 《流畅的Python》读书笔记——接口:从协议到抽象基类
- 读懂hadoop、hbase、hive、spark分布式系统架构
- 独立站电商广告和营销洞察
- 韦东山freeRTOS系列教程之【第六章】信号量(semaphore)
- 使用 MQL5 绘制阻力和支撑级别
- 3dmax打开错误html,Windows安装3dmax软件失败提示错误三种解决办法
- 全球移动通信系统GSM
- SQL Server 2008 Express 安装配置详细教程(附详细截图)
- 伯禹 动手学深度学习 打卡08 之 深度卷积神经网络(AlexNet)
- Joplin+坚果云同步
- 跨考计算机—努力换青春无悔(纪录篇)
- NodeMCU(ESP8266)使用HTTP Get和Post
- Java获取上周一周末和上月初月末