2019 The 19th Zhejiang University Programming Contest
感想:
今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发。最后虽然跟大家题数一样(6题),然而输在罚时。
只能说,水题还是刷得少,看到签到都没灵感实在不应该。
题目链接:http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391
A:简单贪心,按高度sort一下就好了,这里用优先队列处理
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional> using namespace std; int M[], F[]; int main(void)
{
int T;
while (scanf("%d", &T) != EOF)
{
while (T--)
{
int n, m;
priority_queue <int, vector<int>, greater <int>> fu, fd, mu, md;
scanf("%d %d", &n, &m);
for (int i = ; i < n; i++)
{
scanf("%d", &M[i]);
}
for (int i = ; i < m; i++)
{
scanf("%d", &F[i]);
}
for (int i = ; i < n; i++)
{
int flag;
scanf("%d", &flag);
if (flag)
{
mu.push(M[i]);
}
else
{
md.push(M[i]);
}
}
for (int i = ; i < m; i++)
{
int flag;
scanf("%d", &flag);
if (flag)
{
fu.push(F[i]);
}
else
{
fd.push(F[i]);
}
}
int ans = ;
// fu <-> md
while (!fu.empty() && !md.empty())
{
if (fu.top() < md.top())
{
// printf("pop: %d %d\n", fu.top(), md.top());
fu.pop();
md.pop();
ans++;
}
else
{
// printf("pop: %d\n", md.top());
md.pop();
}
}
// fd <-> mu
while (!mu.empty() && !fd.empty())
{
if (mu.top() < fd.top())
{
// printf("pop: %d %d\n", mu.top(), fd.top());
mu.pop();
fd.pop();
ans++;
}
else
{
// printf("pop: %d\n", fd.top());
fd.pop();
}
}
printf("%d\n", ans);
}
}
return ;
}
B:找规律,显然是不停把n除二加起来,高精就用java
import java.util.*;
import java.lang.*;
import java.math.BigInteger; public class Main { public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
while (cin.hasNextInt())
{
int t=cin.nextInt();
while (t-->0){
BigInteger ans=BigInteger.ZERO;
BigInteger x=cin.nextBigInteger();
while (!x.equals(BigInteger.ONE)){
x=x.divide(BigInteger.valueOf(2));
ans=ans.add(x);
}
System.out.println(ans);
}
}
}
}
C:模拟
#include <cstdio> char t[][];
bool vis[][]; const int p3[] = {, , , , , }; const int movement[][] =
{
{, }, // DOWN
{, }, // RIGHT
{-, }, // UP
{, -} // LEFT
}; void init(int n, int m)
{
for (int i = ; i < n; i++)
{
for (int j = ; j < m; j++)
{
vis[i][j] = false;
}
}
} int solve(void)
{
int ans = ;
int n, m;
int a, b;
long long int k;
scanf("%d %d", &n, &m);
scanf("%d %d %lld", &a, &b, &k);
a--;
b--;
char cmd[];
scanf(" %s", cmd);
init(n, m);
for (int i = ; i < n; i++)
{
scanf(" %s", t[i]);
for (int j = ; j < m; j++)
{
t[i][j] -= '';
}
}
while (k--)
{
int x = p3[] * t[a][b]
+ p3[] * t[a - ][b]
+ p3[] * t[a + ][b]
+ p3[] * t[a][b - ]
+ p3[] * t[a][b + ];
if (vis[a][b])
{
return ans;
}
vis[a][b] = true;
if (cmd[x] == 'D')
{
int na = a + movement[][], nb = b + movement[][];
if (t[na][nb] == ) return ans;
else a = na, b = nb;
}
else if (cmd[x] == 'R')
{
int na = a + movement[][], nb = b + movement[][];
if (t[na][nb] == ) return ans;
else a = na, b = nb;
}
else if (cmd[x] == 'U')
{
int na = a + movement[][], nb = b + movement[][];
if (t[na][nb] == ) return ans;
else a = na, b = nb;
}
else if (cmd[x] == 'L')
{
int na = a + movement[][], nb = b + movement[][];
if (t[na][nb] == ) return ans;
else a = na, b = nb;
}
else if (cmd[x] == 'P')
{
if (t[a][b] == )
{
t[a][b] = ;
ans++;
init(n, m);
}
}
else if (cmd[x] == 'I')
{
return ans;
}
}
return ans;
} int main(void)
{
int T;
while (scanf("%d", &T) != EOF)
{
while (T--)
{
printf("%d\n", solve());
}
}
return ;
}
D:上一题的人工智能版,要你构造特定程序捡垃圾。方法是走回字形,比如我们选定顺时针方向走,那么当我们走到左边靠墙位置的时候,如果右手边有垃圾,那么我们往右走一格再继续往上走。如果走到地图中间位置(四周没垃圾)就往上走。如果机器人走了连续相同方向n次就让机器人“抖动”一下(属实人工智能调参)。然而cy他们队就是A了(神仙啊
E:从右往左扫一次就好了,队友没开LL导致wa一发要批评
#include <cstdio> long long int a[], b[]; int main(void)
{
int T;
while (scanf("%d", &T) != EOF)
{
while (T--)
{
int n;
scanf("%d", &n);
for (int i = ; i < n; i++)
{
scanf("%lld", &a[i]);
}
for (int i = ; i < n; i++)
{
scanf("%lld", &b[i]);
}
bool flag = true;
for (int i = n - ; i >= ; i--)
{
if (b[i] >= a[i])
{
if (i)
{
b[i - ] += b[i] - a[i];
}
}
else
{
flag = false;
break;
}
}
printf(flag ? "Yes\n" : "No\n");
}
}
return ;
}
F:神仙题
G:非常简单的贪心
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional> using namespace std; int M[], F[]; int main(void)
{
int T;
while (scanf("%d", &T) != EOF)
{
while (T--)
{
int n, k;
scanf("%d %d", &n, &k);
priority_queue <long long int> pos, neg;
for (int i = ; i < n; i++)
{
int tmp;
scanf("%d", &tmp);
if (tmp > )
{
pos.push(tmp);
}
else
{
neg.push(-tmp);
}
}
long long int ans = , maxn = ;
while (!pos.empty())
{
ans += * pos.top();
maxn = max(pos.top(), maxn);
int cnt = k - ;
pos.pop();
while (cnt-- && !pos.empty())
{
pos.pop();
}
}
while (!neg.empty())
{
ans += * neg.top();
maxn = max(neg.top(), maxn);
int cnt = k - ;
neg.pop();
while (cnt-- && !neg.empty())
{
neg.pop();
}
}
printf("%lld\n", ans - maxn);
}
}
return ;
}
H:救公主,边双相关的题目(然而队友最后没撸出来)
I:要求逆元的看不懂的题目
J:签到(wa了7次,三个人都没睡醒。这里我马上想到了可以输出n×2和n×3,然而忘记特判n==1的情况……)
#include<iostream>
#include<cstdio>
#include<cstdlib> using namespace std; typedef long long ll; ll read()
{
ll x = ; char c = getchar(); ll flag = ;
while (c < '' || c > '')
{
if (c == '-')
{
flag = -;
}
c = getchar();
}
while (c >= '' && c <= '')x = x * 10ll + c - '', c = getchar();
return x;
} int main()
{
ll T;
while (scanf("%lld", &T) == )
{
while (T--)
{
ll x;
x = read();
if (x % == )
{
printf("4 %lld\n", + x);
}
else
{
printf("15 %lld\n", + x);
}
}
} return ;
}
2019 The 19th Zhejiang University Programming Contest的更多相关文章
- 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 ...
- 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 15th Zhejiang University Programming Contest
a ZOJ 3860 求和大家不一样的那个数,签到,map水之 #include<cstdio> #include<map> using namespace std; map ...
- ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
- 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表示 ...
随机推荐
- SQLite保存报错sqlite.SQLiteConstraintException: UNIQUE constraint failed: ······ code 1555
往数据库里保存数据的时候报错,用的afinal框架,明明在save操作之前执行了一遍deleteAll操作,还是报错. 百度了一下说报这种错有两种情况:一是定义的字段为not null ,插入时对应的 ...
- (网页)angular中实现li或者某个元素点击变色的两种方法(转)
转自脚本之家: 本篇文章主要介绍了angular中实现li或者某个元素点击变色的两种方法,非常具有实用价值,需要的朋友可以参考下 本文介绍了angular中实现li或者某个元素点击变色的两种方法,分享 ...
- flask表单
一.原生表单 模板页面 <form action="{{ url_for('check') }}" method="post"> <p> ...
- Yii1.1.16学习记录
最近工作中用到Yii框架,为此专门在网上找了些相关教程学一下,尽管教程比较老,但学完后至少对Yii框架有了基本了解,特别是widget的使用,感觉Yii真的很强大. 一.框架介绍与安装 框架源码下载 ...
- 天池新人赛-天池新人实战赛o2o优惠券使用预测(一)
第一次参加天池新人赛,主要目的还是想考察下自己对机器学习上的成果,以及系统化的实现一下所学的东西.看看自己的掌握度如何,能否顺利的完成一个分析工作.为之后的学习奠定基础. 这次成绩并不好,只是把整个机 ...
- [Kali_Debian] 清除无用的库文件(清理系统,洁癖专用)-布布扣-bubuko.com - Google Chrome
[Kali_Debian] 清除无用的库文件(清理系统,洁癖专用) 时间:2014-11-07 16:25:36 阅读:1486 评论:0 收藏:0 [点我收藏 ...
- pymongo的用法
先看一下官方给出的简单例子,涵盖了大部分内容: >>> import pymongo >>> client = pymongo.MongoClient(" ...
- EasyUI datagrid.getSelections 没有返回正确的选择行数
Actually i solved the problem. It was because the idField of the table i was using was incorrect. it ...
- [MapReduce_8] MapReduce 中的自定义分区实现
0. 说明 设置分区数量 && 编写自定义分区代码 1. 设置分区数量 分区(Partition) 分区决定了指定的 Key 进入到哪个 Reduce 中 分区目的:把相同的 Key ...
- js入门-文本框输入特定内容控制另一个文本框
在填写表单时,有时需要某些文本框隐藏,当一文本框输入特定内容时才会显示隐藏的文本框,这一功能可以用onchange事件或oninput事件实现.下面对比下两种方法实现的区别: onchange()定义 ...