7.6 I POJ 3185 The Water Bowls
来源:互联网 发布:机锋市场淘宝店 编辑:程序博客网 时间:2024/05/16 14:57
题意:
给20个排成一排的碗,有正有倒,某操作可以一次翻3个碗,求最少操作几次,使得所有碗正过来。
思路:
明显的暴力。
代码:
#include <iostream>#include <algorithm>#include <cstring>#include <map>#include <cstdio>using namespace std;const int maxn=10005;struct Ant{ int x; char c;}ant[maxn],pos[maxn];bool cmp(Ant a,Ant b){ return a.x<b.x;}bool cmp2(int a,int b){ return ant[a].x<ant[b].x;}int r[maxn],rr[maxn];int l,n,m;int main(){ ios::sync_with_stdio(0); int T; cin>>T; for(int t=1;t<=T;t++){ cin>>l>>m>>n; map<int,int> point; for(int i=0;i<n;i++){ cin>>ant[i].x>>ant[i].c; int flag=(ant[i].c=='R')?1:-1; pos[i].x=ant[i].x+flag*m; point[pos[i].x]++; pos[i].c=ant[i].c; r[i]=i; } sort(r,r+n,cmp2); sort(pos,pos+n,cmp); for(int i=0;i<n;i++){ rr[r[i]]=i; } cout<<"Case #"<<t<<':'<<endl; for(int i=0;i<n;i++){ if((pos[rr[i]].x<=l)&&(pos[rr[i]].x>=0)) { cout<<pos[rr[i]].x<<' '; if(point[pos[rr[i]].x]>1)cout<<"Turning"<<endl; else cout<<pos[rr[i]].c<<endl; } else cout<<"Fell off"<<endl; } cout<<endl; } return 0;}
0 0
- 7.6 I POJ 3185 The Water Bowls
- poj 3185 The Water Bowls
- POJ 3185 (The Water Bowls)
- POJ 3185 The Water Bowls
- poj 3185 The Water Bowls
- POJ 3185 The Water Bowls
- POJ 3185 The Water Bowls
- POJ-3185-The Water Bowls
- poj-3185 The Water Bowls
- The Water Bowls POJ 3185
- poj 3185 The Water Bowls 高斯消元
- poj -- 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls(高斯消元)
- POJ 3185 The Water Bowls(高斯消元)
- poj 3185 The Water Bowls (高斯消元)
- POJ 3185 The Water Bowls(高斯消元)
- POJ - 3185 The Water Bowls (反转)
- 【华为OJ】删除字符串中出现次数最少的字符
- 除法问题
- Android中.9图片的含义及制作教程
- 点击tr选中每一行前面的checkbox
- Unity常用的函数和遇到的C#的知识整理
- 7.6 I POJ 3185 The Water Bowls
- 解决wordpress页面加载慢的问题
- Leetcode编程练习一:盗马三则
- Hive错误:Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)
- 浅谈android如何利用webView调用网页链接来调用QQ临时会话类似QQ客服
- 了解和使用keystone(二)安装keystone
- 从程序员到CTO的Java技术路线图
- 红色警报(PAT)
- hadoop自带例子wordcount的具体运行步骤