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. js各种宽高(2)

    在javascript和jquery中,都有对各种高度的写法,在这里,我们就着重讲一下窗口.文档等高度的理解.(宽度和高度差不多!) jquery的各种高度 首先来说一说$(document)和$(w ...

  2. int 类型 占多少字节是由什么决定的

    int 类型占据多少字节?到底是跟编译器有关?还是系统来决定的? 1. CPU的设计者才不管你在上面跑什么程序.他们只是按着他们的想法来设计.而int的大小,至少在C/C++中,标准只说可以由实现者自 ...

  3. 种树 (codevs 1653) 题解

    [问题描述] 一条街的一边有几座房子.因为环保原因居民想要在路边种些树.路边的地区被分割成块,并被编号为1..n.每个块大小为一个单位尺寸并最多可种一棵树.每个居民想在门前种些树并指定了三个号码b,e ...

  4. python之ftplib库

    检测ftp是否可用 #!/usr/bin/python #coding:utf-8 from ftplib import FTP def ftp_open(ip,user,passwd): try: ...

  5. Knockout.Js学习目录

    1.Knockout.Js(简介) 2.Knockout.Js(监控属性Observables) 3.Knockout.Js(属性绑定) 4.Knockout.Js(事件绑定) 5.Knockout. ...

  6. 条款5:了解C++提供的默认函数

    当我们定义一个类时,如果没有声明任何函数,那么C++编译器会默认提供4个函数:默认构造函数.复制构造函数.赋值操作符函数.析构函数,并且这些函数默认都是public且inline的.因此,当你定义如下 ...

  7. 一:java概述:

    1991 年Sun公司的James Gosling等人开始开发名称为 Oak 的语言,希望用于控制嵌入在有线电视交换盒.PDA等的微处理器: 1994年将Oak语言更名为Java: Java的三种技术 ...

  8. 硬件相关-ADC原理(未完成)

    一.模数转换的一般步骤: 1)采样和保持 为了把模拟信号转换成对应的数字信号,必须首先将模拟量每隔一定时间抽取一次样值,使时间上连续变化的模拟量变为一个时间上断续变化的模拟量,这个过程称为采样. 为了 ...

  9. Lua与C++交互初探之Lua调用C++

    Lua与C++交互初探之Lua调用C++ 上一篇我们已经成功将Lua的运行环境搭建了起来,也成功在C++里调用了Lua函数.今天我来讲解一下如何在Lua里调用C++函数. Lua作为一个轻量级脚本语言 ...

  10. opencv颜色识别代码分享

    android 平台 opencv 实现颜色识别代码:http://www.eyesourcecode.com/thread-40682-1-1.htmlopencv的颜色识别简单实现的代码:http ...