栈应用--Codeforces Round #205 (Div. 2)B
来源:互联网 发布:ae软件都能做什么 编辑:程序博客网 时间:2024/04/28 16:26
自己写的代码还是太挫啊。。。
#include <iostream>#include <stack>using namespace std;int n;stack<int> ids[101];int hp[200];int df[2];int main(){ cin >> n; for (int i = 0; i < 2*n; i++) { int a; cin >> a; ids[a].push(i); } int x = 0; for (int i = 0; i <= 100; i++) if (ids[i].size() == 1) { int id = ids[i].top(); ids[i].pop(); hp[id] = x; df[x]++; x = (x+1)%2; } for (int i = 0; i <= 100; i++) if (!ids[i].empty()) { df[0]++; df[1]++; while (!ids[i].empty()) { int id = ids[i].top(); ids[i].pop(); hp[id] = x; x = (x+1)%2; } } cout << df[0]*df[1] << "\n"; for (int i = 0; i < 2*n; i++) cout << hp[i]+1 << " "; return 0;}
- 栈应用--Codeforces Round #205 (Div. 2)B
- Codeforces Round #205 (Div. 2) B. Two Heaps
- Codeforces Round #205 (Div. 2) B. Two Heaps
- Codeforces Round #205 (Div. 2) B. Two Heaps
- Codeforces Round #205 (Div. 2) B. Two Heaps
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Codeforces Round #203 (Div. 2) B. Resort
- Codeforces Round #206 (Div. 2) - b
- Codeforces Round #202 (Div. 2)B-贪心
- Keil总是出现“File has been changed outside the editor, reload?”提示
- js技巧
- MyEclipse中的工程发布到Tomcat
- MB525 系统软件说明
- Java定时调度之Timer/TimerTask
- 栈应用--Codeforces Round #205 (Div. 2)B
- maven 架设 struts2 注解方式 权限控制
- davinci平台的I2C驱动(非GPIO口模拟i2c)
- 用户空间访问I2C设备驱动
- 初学者如何查阅自然语言处理(NLP)领域学术资料
- Android的init过程详解(一)
- xCode5增加第三方framework包有问题
- 黑马程序员_java语法
- asp.net4 报 “请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理”