a  ZOJ 3860

求和大家不一样的那个数,签到,map水之

 #include<cstdio>
#include<map>
using namespace std;
map<int,int> mp;
int main(){
int t,n,x;
while(~scanf("%d",&t)){
while(t--){
scanf("%d",&n);
mp.clear();
while(n--){
scanf("%d",&x);
mp[x]++;
}
if(mp.begin()->second==){
printf("%d\n",mp.begin()->first);
}
else{
printf("%d\n",mp.rbegin()->first);
}
}
}
return ;
}

ZOJ 3861

求输入的整数串有多少种合法的排列,枚举所有排列判断合法

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#define mt(a,b) memset(a,b,sizeof(a))
using namespace std;
const int M=;
int a[M];
vector< vector<int> > ans;
vector<int> v;
int n;
bool vis[M];
bool good(int x,int y){
if(x>y) swap(x,y);
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
if(x==&&y==) return vis[];
return true;
}
bool judge(){
mt(vis,);
for(int i=;i<n;i++){
if(good(a[i-],a[i])){
vis[a[i-]]=true;
vis[a[i]]=true;
}
else return false;
}
return true;
}
int main(){
int t;
while(~scanf("%d",&t)){
while(t--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
}
sort(a,a+n);
ans.clear();
do{
if(judge()){
v.clear();
for(int i=;i<n;i++){
v.push_back(a[i]);
}
ans.push_back(v);
}
}while(next_permutation(a,a+n));
int la=ans.size();
printf("%d\n",la);
for(int i=;i<la;i++){
for(int j=;j<n;j++){
printf("%d%c",ans[i][j],j==n-?'\n':' ');
}
}
}
}
return ;
}

ZOJ 3862

有n个线段,知道每个线段端点的编号和坐标,每一步能交换一对编号的坐标,问能否在n+10步内使得所有线段不相交。

按点排序,x小,x相同y小,然后依次遍历,每次取两个点,若恰好是一对,无需操作,若不是一对,将第二个点与第一个点的对应点交换。

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#define mt(a,b) memset(a,b,sizeof(a))
using namespace std;
const int M=2e5+;
struct point{
int x,y;
friend bool operator <(const point &a,const point &b){
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
}p[M],s[M];
int to[M];
typedef pair<int,int> pii;
map<pii,int> mp;
vector<point> ans;
int main(){
int t,n,x,y;
while(~scanf("%d",&t)){
while(t--){
scanf("%d",&n);
int n2=n*;
mp.clear();
for(int i=;i<n2;i++){
scanf("%d%d",&p[i].x,&p[i].y);
s[i]=p[i];
mp[make_pair(p[i].x,p[i].y)]=i;
}
sort(s,s+n2);
for(int i=;i<n;i++){
scanf("%d%d",&x,&y);
x--;
y--;
to[x]=y;
to[y]=x;
}
ans.clear();
for(int i=;i<n2;i+=){
point a=s[i];
point b=s[i+];
int aid=mp[make_pair(a.x,a.y)];
int bid=mp[make_pair(b.x,b.y)];
if(to[aid]==bid) continue;
int cid=to[aid];
mp[make_pair(p[cid].x,p[cid].y)]=bid;
swap(p[bid],p[cid]);
a.x=bid;
a.y=cid;
ans.push_back(a);
}
int la=ans.size();
printf("%d\n",la);
for(int i=;i<la;i++){
printf("%d %d\n",ans[i].x+,ans[i].y+);
}
}
}
return ;
}

end

The 15th Zhejiang University Programming Contest的更多相关文章

  1. ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest

    一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...

  2. zoj 4020 The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light(广搜)

    题目链接:The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light 题解: 题意 ...

  3. The 16th Zhejiang University Programming Contest-

    Handshakes Time Limit: 2 Seconds      Memory Limit: 65536 KB Last week, n students participated in t ...

  4. The 19th Zhejiang University Programming Contest - H

    Princess Cjb is caught by Heltion again! Her knights Little Sub and Little Potato are going to Helti ...

  5. The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror) B"Even Number Theory"(找规律???)

    传送门 题意: 给出了三个新定义: E-prime : ∀ num ∈ E,不存在两个偶数a,b,使得 num=a*b;(简言之,num的一对因子不能全为偶数) E-prime factorizati ...

  6. The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror)

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A     Thanks, TuSimple! Time ...

  7. 2019 The 19th Zhejiang University Programming Contest

    感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. ...

  8. Mergeable Stack 直接list内置函数。(152 - The 18th Zhejiang University Programming Contest Sponsored by TuSimple)

    题意:模拟栈,正常pop,push,多一个merge A B 形象地说就是就是将栈B堆到栈A上. 题解:直接用list 的pop_back,push_back,splice 模拟, 坑:用splice ...

  9. 152 - - G Traffic Light 搜索(The 18th Zhejiang University Programming Contest Sponsored by TuSimple )

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5738 题意 给你一个map 每个格子里有一个红绿灯,用0,1表示 ...

随机推荐

  1. habse的CopyTable

    需求:对hbase的一张表进行拷贝 一.table1的内容如下 hbase(main)::> scan 'table1' ROW COLUMN+CELL column=f1:age, times ...

  2. WCF全面解析第一章 WCF 简介

    1.WCF中的 "A","B","C" 介绍 我们先看个生活中的例子,某一天,公司的领导让你去送一份合同文件,送文件的过程你可以选择的交通方 ...

  3. linux 修改系统时间

    首先进入/proc/sys/xen,执行以下命令 [root@test]#cd   /proc/sys/xen[root@test]#echo 1 > independent_wallclock ...

  4. SQL Server 一些关键字详解(一)

    1.CROSS APPLY 和OUTER APPLY MSDN解释如下(个人理解不是很清晰): 使用 APPLY 运算符可以为实现查询操作的外部表表达式返回的每个行调用表值函数.表值函数作为右输入,外 ...

  5. PHP 学习笔记 01

    例子: 为什么要学PHP 主观原因: 前段时间在学校处理了毕业的一些事情,回到上海后开始了找工作的旅程.意向工作是WPF开发或者ASP.NET 作为后端的WEB开发. 陆陆续续一直在面试,其中有一家公 ...

  6. .NET开源工作流RoadFlow-流程设计-保存与发布

    如果流程未设计完时可以先保存,以后再打开接着设计.点击工具栏上的保存按钮即可保存当前流程设计: 如果下次要接着设计,则可以打开该流程继续设计: 如果流程设计完成,可以点击安装按钮来发布流程,流程安装成 ...

  7. SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation.

    1.前一天安装号db2后,做了如下处理: ************************************************************ 修改 /etc/sudoers 文件 ...

  8. [C#] 记-TinyMapper使用

    What is TinyMapper TinyMapper - a tiny and quick object mapper for .Net. The main advantage is perfo ...

  9. JavaScript高级程序设计之作用域链

    JavaScript只有函数作用域:每个函数都有个作用域链直达window对象. 变量的查找由内而外层层查找,找到即止. 同时不仅可以查找使用,甚至可以改变外部变量. var color = &quo ...

  10. c++ 性能

    http://blog.sina.com.cn/s/blog_4a471ff601013vud.html http://www.linuxidc.com/Linux/2015-06/118874.ht ...