HZNU Training 2 for Zhejiang Provincial Collegiate Programming Contest 2019
赛后总结:
T:今天下午参加了答辩比赛,没有给予队友很大的帮助。远程做题的时候发现队友在H上遇到了挫折,然后我就和她们说我看H吧,她们就开始做了另外两道题。今天一人一道题。最后我们在研究一道dp的时候,被疯狂卡时间和内存,也是最后三十分钟开始写的,感觉受到了挫折。┭┮﹏┭┮
J:今天开场一个多小时都在看H,还是没打出来,就换了别的题。彭彭说他打过F,F就交给他了。看了G好久,感觉好像能做,就做出来了(while循环没弄好,T了一次,简直是个傻子)。最后看了E和J,打了J,还是wa了,自己想的样例没过。。。。最后看了E,先是MLE,改成一维数组之后又T了,心态爆炸。今天一人打了一题,太菜了。
P:下午看到一道自己以前敲过的,然而。。不记得题目意思了(上回也是题目看不懂。。)在金姐的帮助下,我想起了大致方向----第一次在比赛过程中A题(tcl)然后,金姐想另一题的时候,我提供了前缀和的思路,但其实还是靠金姐啦! 谭总A掉我和金姐想不出的H后,就没有然后了。
E - Coins POJ - 1742
F - Break Standard Weight ZOJ - 3706
题意:给你两个标准重量,你可以将其中一个拆分成两个新的重量,问你通过这三个重量,最多能称出几种不同的重量
暴力模拟出三种重量相加减后的值,再去重、去0。
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<vector>
#include<ctime>
#include<stack>
using namespace std;
#define inf 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long
#define MAXN 300010
#define MAXM 10000010
int n;
ll a[MAXN];
set<int> se;
int main()
{
int t;
scanf("%d",&t);
int x,y;
while(t--){
scanf("%d %d",&x,&y);
int maxx=;
for(int i=;i<x;i++){//其实循环到x/2就OK了
int a,b,c;
a=i;
b=x-i;
c=y;
se.clear();
se.insert(a);
se.insert(b);
se.insert(c);
se.insert(a+b);
se.insert(a+c);
se.insert(c+b);
se.insert(abs(a-b));
se.insert(abs(a-c));
se.insert(abs(b-c));
se.insert(a+b+c);
se.insert(abs(a+b-c));
se.insert(abs(a-b+c));
se.insert(abs(a-b-c));
se.insert(abs(b-c-a));
se.insert(abs(b+c-a));
se.insert(abs(b-c+a));
set<int>::iterator it=se.begin();
if(*it==){
maxx=max(maxx,(int)se.size()-);
}
else{
maxx=max(maxx,(int)se.size());
}
}
for(int i=;i<y;i++){
int a,b,c;
a=i;
b=y-i;
c=x;
se.clear();
se.insert(a);
se.insert(b);
se.insert(c);
se.insert(a+b);
se.insert(a+c);
se.insert(c+b);
se.insert(abs(a-b));
se.insert(abs(a-c));
se.insert(abs(b-c));
se.insert(a+b+c);
se.insert(abs(a+b-c));
se.insert(abs(a-b+c));
se.insert(abs(a-b-c));
se.insert(abs(b-c-a));
se.insert(abs(b+c-a));
se.insert(abs(b-c+a));
set<int>::iterator it=se.begin();
if(*it==){
maxx=max(maxx,(int)se.size()-);
}
else{
maxx=max(maxx,(int)se.size());
}
}
printf("%d\n",maxx);
}
}
G - Frets On Fire CodeForces - 1119D
题意:给你一个 s[0][0] ~ s[0][n-1] ,s[i][j] = s[i][0] + j ,查询 s[0][L] ~ s[n-1][R] 有几个不同的数。
s[0][L] ~ s[n][R] 有几个不同的数只跟区间长度有关,将 s[0][0] ~ s[0][n-1] 丢到set中去重排序得到 a[0] ~ a[m],a[i]的贡献为 len - max( len - ( a[i] - a[i-1] ) , 0 )。
令 l[i] = a[i] - a[i-1] ,将 l 从小到大排序,假设 x 为 第一个 l[x] >= len ,则 ans = ∑x l[i] + len * (n-x)。
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<vector>
#include<ctime>
#include<stack>
using namespace std;
#define inf 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long
#define MAXN 300010
#define MAXM 10000010
int n;
set<ll>s;
vector<ll>v;
ll sum[MAXN];
int main()
{
ll a;
scanf("%d", &n);
for (int i = ; i < n; ++i)
{
scanf("%lld", &a);
s.insert(a);
}
n = s.size();
set<ll>::iterator it , itt;
itt = it = s.begin();
it++;
for (; it != s.end(); it++)
{
v.push_back(*it - *itt);
itt++;
}
sort(v.begin(), v.end());
for (int i = ; i < n; ++i)
sum[i] = sum[i - ] + v[i - ];
int k;
scanf("%d", &k);
ll l, r;
ll len;
while (k--)
{
scanf("%lld %lld", &l, &r);
len = r - l + ;
if (upper_bound(v.begin(), v.end(), len) == v.end())
{
printf("%lld ", sum[n - ] + len);
}
else
{
int t = upper_bound(v.begin(), v.end(), len) - v.begin();
printf("%lld ", len*(n - t) + sum[t]);
}
}
}
H - Pavel and Triangles CodeForces - 1119E
题意:给你n种木柜,An-1种木棍表示为2^(n-1)的长度有多少根,问你最多可以组成几种不同的等腰或等边三角形。
贪心。因为第一根木棍长度最小,无法成为后面三角形的腰,所以减去等边三角形,只能作为底边。然后对于1~n-1的边长,先看能分成几个2,与底边总数进行比较,然后取小的。接下来就是一系列删减的操作。当然也要算等边三角形的啦。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
const int maxn = 3e5+;
#define MAX_DISTANCE 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long
#define SIGN(A) ((A > 0) ? 1 : -1)
#define NO_DISTANCE 1000000
const double INF = 10000000000.00;
#define LL long long int
#define mod 1000000007
int gcd(int a, int b) { return a == ? b : gcd(b % a, a); }
int n;
ll a[maxn],num;
int main()
{
scanf("%d", &n);
for (int i = ; i < n; i++)
scanf("%lld", &a[i]);
ll ans = a[] / ;
a[] %= ;
ll sum = a[];
for (int i = ; i < n; i++)
{
num = min(sum, a[i] / );
ans += num;
sum -= num;
a[i] -= num*;
ans += a[i] / ;
a[i] %= ;
sum += a[i];
}
cout << ans<<endl;
return ;
}
I - Tesla CodeForces - 996C
题意:一个4*n大小的停车场,第一行和第四行为有编号停车位,中间两行为带有编号的车辆。车辆需要停到对应的编号车位里。车辆可以进行左右移动,以及在边缘进行上下移动,移动一下算一步。如果可以在20000步内,所有车辆都可以停到自己的车位上,就输出解法,不可以输出-1.
一道模拟和思维的题目。我们可以通过适当变换,将车辆和车位各变成一维数组,对车辆进行移动,即对数组进行移动,尝试是否可以对准车位,然后需要记录一下路径。
/*
I have a dream!A AC deram!!
orz orz orz orz orz orz orz orz orz orz orz
orz orz orz orz orz orz orz orz orz orz orz
orz orz orz orz orz orz orz orz orz orz orz */ #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1e9 + ;
const int N = 4e5 + ;
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
int a[][];
int n, k, s;
struct node
{
int id, x, y;
node(int _id, int _x, int _y) {
id = _id;
x = _x;
y = _y;
};
};
vector<node>ans; void stop()
{
for (int i = ; i < * n; i++)
{
if (a[][i] && (a[][i] == a[][i]))
{
ans.push_back(node( a[][i], i / n == ? : , i % n + ));
a[][i] = ;
k--;
} }
}
bool judge()
{
stop();
for (int i = ; i < * n; i++)
{
if (!a[][i])
return true;
}
return false;
} void turn()
{
vector<node>v1, v2;
int t = a[][ * n - ];
for (int i = * n - ; i >= ; i--)
{
a[][i] = a[][i - ];
if (a[][i])
{
if (i > s)
v1.push_back(node(a[][i], i / n == ? : , i % n + ));
else
v2.push_back(node(a[][i], i / n == ? : , i%n + ));
}
}
a[][] = t;
if (t)
v2.push_back(node (t, , ));
vector<node>::iterator it;
for (it = v2.begin(); it != v2.end(); it++)
ans.push_back(*it);
for (it = v1.begin(); it != v1.end(); it++)
ans.push_back(*it);
}
int main()
{
scanf("%d %d", &n, &k);
for (int i = ; i < n; i++)
scanf("%d", &a[][i]);
for (int i = ; i < n; i++)
scanf("%d", &a[][i]);
for (int i = * n - ; i >= n; i--)
scanf("%d", &a[][i]);
for (int i = * n - ; i >= n; i--)
scanf("%d", &a[][i]);
if (!judge())
{
printf("-1\n");
return ;
}
for (int i = ; i < * n; i++)
{
if (!a[][i])
{
s = i;
break;
}
}
while (k)
{
stop();
turn();
s = (s + ) % ( * n);
}
printf("%d\n", ans.size());
vector<node>::iterator it;
for (it = ans.begin(); it != ans.end(); it++)
{
int x = (*it).x;
int y = (*it).y;
int id = (*it).id;
if (x == || x == )
y = n - y + ;
printf("%d %d %d\n", id, x, y);
} return ;
}
HZNU Training 2 for Zhejiang Provincial Collegiate Programming Contest 2019的更多相关文章
- HZNU Training 4 for Zhejiang Provincial Collegiate Programming Contest 2019
今日这场比赛我们准备的题比较全面,二分+数论+最短路+计算几何+dp+思维+签到题等.有较难的防AK题,也有简单的签到题.为大家准备了一份题解和AC代码. A - Meeting with Alien ...
- HZNU Training 1 for Zhejiang Provincial Collegiate Programming Contest
赛后总结: TJ:今天我先到实验室,开始看题,一眼就看了一道防AK的题目,还居然觉得自己能做wwww.然后金姐和彭彭来了以后,我和他们讲了点题目.然后金姐开始搞dfs,我和彭彭看榜研究F题.想了很久脑 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial ...
随机推荐
- http协议(一):http协议基础知识
1 协议类型 l HTTP 超文本传输协议 通过浏览器和服务器进行数据交互,进行超文本(文本.图片.视频等)传输的规定 l HTTPS 安全超文本传输协议 l FTP 文本传输协议 l ...
- PYNQ上手笔记 | ① 启动Pynq
现在人工智能非常火爆,一般的教程都是为博硕生准备的,太难看懂了,分享一个非常适合小白入门的教程,不仅通俗易懂而且还很风趣幽默,点☞这里☜进入传送门~ = = = = 我是华丽的分割线 = ...
- 【Java例题】1.2计算n的m次方
package study; import java.util.*; import java.math.*; public class study { public static void main( ...
- C#使用代理IP发送请求
https://www.cnblogs.com/benbenfishfish/p/5830149.html 获取可代理的IP https://www.cnblogs.com/ShalenChe/p ...
- 两个 github 账号混用,一个帐号提交错误
问题是这样,之前有一个github帐号,因为注册邮箱的原因,不打算继续使用了,换了一个新的邮箱注册了一个新的邮箱帐号.新账号提交 就会出现下图的问题,但是原来帐号的库还是能正常提交. 方法1:添加 ...
- 算法与数据结构基础 - 排序(Sort)
排序基础 排序方法分两大类,一类是比较排序,快速排序(Quick Sort).归并排序(Merge Sort).插入排序(Insertion Sort).选择排序(Selection Sort).希尔 ...
- Mock Server的搭建
一.概述 我们系统与第三方开票系统有交互,场景是我们系统请求第三方开票系统,第三方开票系统根据我们的请求数据,生成开票信息然后返回发票号或异常信息,我们根据返回的信息做对应的处理.因为配合上存在一些障 ...
- Spring Boot Security Oauth2之客户端模式及密码模式实现
Spring Boot Security Oauth2之客户端模式及密码模式实现 示例主要内容 1.多认证模式(密码模式.客户端模式) 2.token存到redis支持 3.资源保护 4.密码模式用户 ...
- net core Webapi基础工程搭建(一)——开发工具及环境
目录 开发工具 版本 后端框架 开发工具 Visual Studio 2019,既然要折腾那就体验最新版的开发工具有什么特殊的地方,之前个人开发使用的是2017. 下载地址:https://visua ...
- 小白学Python(4)——用Python创建PPT
python-pptx是一个用于创建和更新PowerPoint(.pptx)文件的Python库. 典型的用途是从数据库内容生成自定义的PowerPoint演示文稿,可通过单击Web应用程序中的链接进 ...