题意:两根导线绕在一起,问能不能拉成两条平行线,只能向两端拉不能绕

思路:从左至右,对+-号分别进行配对,遇到连续的两个“+”或连续的两个“-”即可消掉,最后如果全部能消掉则能拉成平行线。拿两根线绕一下就理解了,也可以一根拉成直线,另一根围着它绕,然后观察能拉成直线的条件。用栈实现就行。

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define fillchar(a, x) memset(a, x, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(a)) typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull; //#ifndef ONLINE_JUDGE
void RI(vector<int>&a,int n){a.resize(n);for(int i=;i<n;i++)scanf("%d",&a[i]);}
void RI(){}void RI(int&X){scanf("%d",&X);}template<typename...R>
void RI(int&f,R&...r){RI(f);RI(r...);}void RI(int*p,int*q){int d=p<q?:-;
while(p!=q){scanf("%d",p);p+=d;}}void print(){cout<<endl;}template<typename T>
void print(const T t){cout<<t<<endl;}template<typename F,typename...R>
void print(const F f,const R...r){cout<<f<<", ";print(r...);}template<typename T>
void print(T*p, T*q){int d=p<q?:-;while(p!=q){cout<<*p<<", ";p+=d;}cout<<endl;}
//#endif
template<typename T>bool umax(T&a, const T&b){return b<=a?false:(a=b,true);}
template<typename T>bool umin(T&a, const T&b){return b>=a?false:(a=b,true);}
template<typename T>
void V2A(T a[],const vector<T>&b){for(int i=;i<b.size();i++)a[i]=b[i];}
template<typename T>
void A2V(vector<T>&a,const T b[]){for(int i=;i<a.size();i++)a[i]=b[i];} const double PI = acos(-1.0);
const int INF = 1e9 + ;
const double EPS = 1e-8; /* -------------------------------------------------------------------------------- */ char s[]; int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
while (~scanf("%s", s)) {
stack<char> S;
for (int i = ; s[i]; i ++) {
char ch = s[i];
if (!S.empty() && ch == S.top()) S.pop();
else S.push(ch);
}
puts(S.empty()? "Yes" : "No");
}
return ;
}

最新文章

  1. Redux教程2:链接React
  2. 一个统计报表sql问题
  3. NOI2018准备 Day11
  4. Emoji表情符号录入MySQL数据库报错的解决方案(MySQL utf8与utf8mb4区别)
  5. 创建线程方式-pthread
  6. Java Switch(String)
  7. dede定义全局变量(include/common.inc.php)及调用方式
  8. Hdu2425-Hiking Trip(优先队列搜索)
  9. Java学习之DAO设计模式
  10. systemd的命令systemctl set-property testSpeed CPUQuota=10%
  11. 小K的H5之旅-HTML的基本结构与基本标签
  12. 十五、Spring Boot 环境变量读取 和 属性对象的绑定
  13. ReSharper 全教程
  14. yyb要填的各种总结的坑
  15. msql分区
  16. 三种方式给apt设置代理
  17. 使用Docker for Windows初体验
  18. html5+PHP,websocket无法连接的问题(Call to undefined function socket_create())
  19. javascript 实现数据结构 - 队列
  20. Ansible 使用普通用户远程执行playbook

热门文章

  1. Java中集合的嵌套
  2. 理解RESTful API
  3. sqlliab7-8
  4. 解决Vue-cli3.0下scss文件编译过慢、卡顿问题
  5. flutter中使用redux之多界面互动
  6. 四、CentOS 6.5 上传和安装Nginx
  7. Hadoop学习笔记(三) ——HDFS
  8. CF思维联系–CodeForces - 223 C Partial Sums(组合数学的先线性递推)
  9. 2019 ICPC 银川网络赛 H. Fight Against Monsters
  10. ASP.NET MVC使用log4net