The 15th Zhejiang University Programming Contest
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 ;
}
b 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 ;
}
c 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的更多相关文章
- ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
- 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 题解: 题意 ...
- The 16th Zhejiang University Programming Contest-
Handshakes Time Limit: 2 Seconds Memory Limit: 65536 KB Last week, n students participated in t ...
- 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 ...
- 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 ...
- The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror)
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A Thanks, TuSimple! Time ...
- 2019 The 19th Zhejiang University Programming Contest
感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. ...
- 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 ...
- 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表示 ...
随机推荐
- php 判断table 是否存在 根据返回值继续下一步的操作
根据sql命令创建数据库或者数据表时候,判断库或者表是否存在比较重要. //要创建的表是否已经存在 function isHaveTable( $dbName,$tableN, $con) //数据 ...
- 华为C语言编程规范
DKBA华为技术有限公司内部技术规范DKBA 2826-2011.5C语言编程规范2011年5月9日发布 2011年5月9日实施华为技术有限公司Huawei Technologies Co., Ltd ...
- 1.html5究竟是什么
1.html5的起源,历史背景…… 按照一般的套路,我这里应该对html5的起源和发展历史,其优越性等大书特书一番.但既然你有意识地专门去找类似的文章,说明你早有相应的认识,就算没有,类似的东西网上也 ...
- JavaWeb之Servlet: ServletConfig 与 ServletContext
ServletConfig对象 什么是ServletConfig对象 ServletConfig对象,叫Servlet配置对象.主要用于加载配置文件的初始化参数. 创建时机 ServletConfig ...
- kettle插入/更新
1.数据库环境 --------------------实时表 ),Info )); ,'张启山','长沙'); ,'尹新月','长沙'); ,'二月红','长沙'); --------------- ...
- sql server 查询数据库所有的表名+字段
SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='Account' SELECT (case when a.colorder= ...
- ExtJs桌面组件(DeskTop)
在desktop\js目录中包含了5个js文件,这5个js文件如下: 还有css样式表:desktop.css,图片素材 在这5个js文件中封装了用于模拟桌面的类,这些类如下: Ext.ux.Star ...
- [转]ldconfig几个需要注意的地方
[转]ldconfig几个需要注意的地方 http://www.cnblogs.com/arci/archive/2011/03/19/1988952.html 1. 往/lib和/usr/lib里面 ...
- How to Notify Command to evaluate in mvvmlight
How to Raize Command to evalituate in mvvm In mvvmlight, we bind our control to the relaycommand obj ...
- C++设计模式——工厂方法模式
本文版权归果冻说所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利.» 本文链接:http://www.jellythink.com/arch ...