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表示 ...
随机推荐
- Android项目实战(三十二):圆角对话框Dialog
前言: 项目中多处用到对话框,用系统对话框太难看,就自己写一个自定义对话框. 对话框包括:1.圆角 2.app图标 , 提示文本,关闭对话框的"确定"按钮 难点:1.对话框边框圆角 ...
- BD是什么角色
BD是什么角色? 在一般创业公司里面,有了产品接下来就是运营了,而运营中很重要的一点就是BD,也就是所谓商务拓展了,俗一点说就是生意的合作拓展 https://www.jianshu.com/p/7d ...
- [20171211][转载]如何实现dbms_output输出没有打开serveroutput on.txt
[20171211]如何实现dbms_output输出没有打开serveroutput on.txt http://orasql.org/2017/12/10/sqlplus-tips-8-dbms_ ...
- [20171206]rman与truncate2.txt
[20171206]rman与truncate2.txt --//上午测试发现truncate的表在做rman备份时还要做8个extents的备份.--//不知道自己的猜测是否正确,选择一个使用UNI ...
- win10怎么查看进程
1.在任务栏右击-任务管理器 2.
- 4.3Python数据类型(3)之字符串类型
返回总目录 目录: 1.字符串的概念 2.字符串的形式 3.字符串的转义符 4.字符串一般操作 5.字符串函数操作 (一)字符串的概念 由单个字符组成的一个集合 (二)字符串的形式 双引号与单引号的效 ...
- 回文数的golang实现
判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数 输入: 输出: true 输入: - 输出: false 解释: 从左向右读, 为 - . 从右向左读, 为 - ...
- 从研发到市场,一个C#程序员半年神奇之旅
序 距离上次在博客园发布文章已经过了大约有一年了,由于最近一系列神奇的际遇,让我非常强烈意愿的提起笔来给大家描述我最近一段时间的经历,希望大家根据我的经历做一些参考,我尽量写的逻辑通顺,如果各位兄弟阅 ...
- Django 使用mysql 数据库流程
创建一个mysql数据库 在settings中配置: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': ...
- JS的局部变量和全局变量
两段JS代码的区别: <script type="text/javascript"> var a = "Hello"; function test( ...