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表示 ...
随机推荐
- Python 基于Python实现批量创建目录
基于Python实现批量创建目录 by:授客QQ:1033553122 测试环境: Python版本:Python 2.7 代码实践 #!/usr/bin/env python # -*- cod ...
- loadrunner 运行脚本-Run-time Settings->General->Additional attributes设置
运行脚本-Run-time Settings->General->Additional attributes设置 by:授客 QQ:1033553122 作用说明 为Vuser脚本提供额外 ...
- JMeter http(s)测试脚本录制器的使用
JMeter http(s)测试脚本录制器的使用 by:授客 QQ:1033553122 http(s) Test Script Recorder允许Jmeter在你使用普通浏览器浏览web应用时,拦 ...
- python爬虫之Beautifulsoup学习笔记
相关内容: 什么是beautifulsoup bs4的使用 导入模块 选择使用解析器 使用标签名查找 使用find\find_all查找 使用select查找 首发时间:2018-03-02 00:1 ...
- Linux Mint Mate 常用
Linux Mint基于Ubuntu Mate 桌面版据说资源占用较少 http://mirrors.tuna.tsinghua.edu.cn/linuxmint-cd/stable/17.3/li ...
- weblogic系列漏洞整理 -- 4. weblogic XMLDecoder 反序列化漏洞(CVE-2017-10271、CVE-2017-3506)
目录 四. weblogic XMLDecoder 反序列化漏洞(CVE-2017-10271) 0. 漏洞分析 1. 利用过程 2. 修复建议 一.weblogic安装 http://www.cnb ...
- CentOS乱码解决方法
linux 中文显示乱码解决办法, 其实是有多种情况的, 有一部分是由于终端默认的设置造成的 vi /etc/sysconfig/i18n 将内容改为LANG="zh_CN.GB18030& ...
- mysql启动失败一例
操作系统版本:Ubuntu 13.04 mysql 版本:mysql-server-5.5 现象:突然之前接到报告说数据库启不来了.第一时间查看硬盘空间,看是否硬盘满了.发现空间使用正常. root@ ...
- win10 文件扩展名的更改
win10 文件扩展名的改 随便打开一个文件夹,最好是"此电脑", 第二行是 " 文件 - 计算机 - 查看 " 在查看里面就可以更改了 ...
- 【BZOJ4946】[NOI2017]蔬菜(贪心)
[BZOJ4946][NOI2017]蔬菜(贪心) 题面 BZOJ 洛谷 UOJ 题解 忽然发现今年\(NOI\)之前的时候切往年\(NOI\)的题目,就\(2017\)年的根本不知道怎么下手(一定是 ...