18/9/22NOIP模拟考

其实本来是有多组数据的,出题人忘记在题面上加了   斜眼笑

期望得分:100;实际得分:100

由于种种原因,拿到题的时候已经过去了0.5h+。。。

然后因为这道题数据范围比较大,所以。。就想到了找规律

没想到居然A了  开心

这道题一共出现了三种做法:

1.出题人的std:据说是旋转坐标系什么鬼的,没听说过。。。

2.某人:从一个点做一个斜率为±1的一次函数,然后。。。如图

3.大部分人(包括我):分别求出两点横纵坐标之差的绝对值,然后取max,完事

4.极少部分人:模拟 or 暴力?

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long LL;
LL n, s, t, c, f; int main() {
freopen("grid.in","r",stdin);
freopen("grid.out","w",stdout);
scanf("%I64d%I64d%I64d%I64d%I64d", &n, &s, &t, &c, &f);
LL a = abs(s - c), b = abs(t - f);
cout << max(a, b) << '\n';
fclose(stdin); fclose(stdout);
return ;
}

极其简短的我的代码 qwq

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cctype>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<cassert>
using namespace std;
typedef long long LL; inline int read() {
int x = , f = ; char ch = getchar(); for (; !isdigit(ch); ch=getchar()) if (ch=='-') f = -;
for (; isdigit(ch); ch=getchar()) x = x * + ch - ''; return x * f;
} LL dx[] = {, , , -};
LL dy[] = {, -, , }; LL getdis(LL a,LL b,LL c,LL d,int flag) {
if (flag) { // black
a = (a - ) / , b = (b - ) / , c = (c - ) / , d = (d - ) / ;
return abs(a - c) + abs(b - d);
}
else { // white
a /= , b /= , c /= , d /= ;
return abs(a - c) + abs(b - d);
}
}
void getxy(LL a,LL b,LL &t1,LL &t2) {
t1 = a + b,t2 = b - a;
}
int main() { freopen("grid.in","r",stdin);
freopen("grid.out","w",stdout); LL Case,n, a, b, c, d, t1, t2, t3, t4, t5, t6;
// cin >> Case;
// while (Case--) { cin >> n >> a >> b >> c >> d; assert(a <= n);
assert(b <= n);
assert(c <= n);
assert(d <= n); t1 = a + b, t2 = b - a;
t3 = c + d, t4 = d - c; int f1, f2;
if ((t1 & ) && (t2 & )) f1 = ;
else f1 = ;
if ((t3 & ) && (t4 & )) f2 = ;
else f2 = ; LL ans = 1e18;
if (f1 == f2) ans = getdis(t1, t2, t3, t4, f1);
else {
for (int i=; i<; ++i) {
LL x = a + dx[i], y = b + dy[i];
if (x >= && x <=n && y >= && y <= n) {
getxy(x, y, t5, t6);
ans = min(ans, getdis(t3, t4, t5, t6, f2) + );
}
}
for (int i=; i<; ++i) {
LL x = c + dx[i], y = d + dy[i];
if (x >= && x <=n && y >= && y <= n) {
getxy(x, y, t5, t6);
ans = min(ans, getdis(t1, t2, t5, t6, f1) + );
}
}
}
cout << ans << "\n";
// }
return ;
}

std

期望得分:0;实际得分:0

其实还是希望有些分的,然而暴力没有调出来。。。

然后就gg了 qwq

正解:如果写了dfs的话,可以看出:我们只要知道上次填的串多长,就可以知道上次使用的字符串。而且对每个位置只需要知道它上次填2或3时是否可行。

$f[i][2/3]$表示当前到$i$,以$i$开头,长度为2/3的的后缀串是否可行。可以转移就记录答案。

如果type ≠ 0,则不需要判断后缀是否相同

为了方便,可以把串反过来

复杂度:O(n)

#include <cstdio>
#include <cstring>
#include <algorithm>
#define pc putchar
const int N=; bool f[N][]/*0:2 1:3*/,ok2[][],ok3[][][];
char s[N]; void Work(const int type) {
memset(f,,sizeof f);
memset(ok2,,sizeof ok2), memset(ok3,,sizeof ok3); scanf("%s",s+);
int n=strlen(s+);
std::reverse(s+,s++n); int tot=; n-=;
if(n>=) f[][]=, ++tot, ok2[s[]-'a'][s[]-'a']=;
if(n>=) f[][]=, ++tot, ok3[s[]-'a'][s[]-'a'][s[]-'a']=; for(int i=; i<=n; ++i) {
int a=s[i]-'a', b=s[i-]-'a', c=s[i-]-'a';
if(f[i-][]||(f[i-][]&&(type||s[i]!=s[i-]||s[i-]!=s[i-]))) {
f[i][]=;
if(!ok2[a][b]) ++tot, ok2[a][b]=;
}
if(f[i-][]||(f[i-][]&&(type||s[i]!=s[i-]||s[i-]!=s[i-]||s[i-]!=s[i-])))//i>=6
{
f[i][]=;
if(!ok3[a][b][c]) ++tot, ok3[a][b][c]=;
}
}
printf("%d\n",tot);
for(int i=; i<&&tot; ++i) {
for(int j=; j<; ++j) {
if(ok2[i][j]) --tot,pc(i+'a'),pc(j+'a'),pc('\n');
for(int k=; k<; ++k)
if(ok3[i][j][k]) --tot,pc(i+'a'),pc(j+'a'),pc(k+'a'),pc('\n');
}
}
} int main() {
freopen("ling.in","r",stdin);
freopen("ling.out","w",stdout); int T,type;
for(scanf("%d%d",&T,&type); T--; Work(type));
return ;
}

std

一看要求期望。。。一脸不可做。。。

整场考试也就瞄了几眼,一点想做的念头都没有。。。

蒻的一批。。。

事实证明,真心难啊 qwq

#include <cstdio>
#include <cctype>
#include <assert.h>
#include <algorithm>
#define gc() getchar()
const int N=5e5+; int n,sz[N],fa[N],q[N],H[N],Enum,to[N],nxt[N];
double pw[N];//2^{-i} inline int read() {
int now=;register char c=gc();
for(;!isdigit(c);c=gc());
for(;isdigit(c);now=now*+c-'',c=gc());
return now;
}
inline void AddEdge(int u,int v) {
fa[v]=u, ++sz[u], ++sz[fa[u]];
to[++Enum]=v, nxt[Enum]=H[u], H[u]=Enum;
}
double Calc(int x) {
if(!sz[x]) return ;//sz:子树内点数
int t=;//t:子节点数
for(int i=H[x]; i; i=nxt[i]) q[t++]=to[i];
if(t==sz[x])//D=2
return -pw[t];
else {
double ans=;
for(int s=; s<<<t; ++s) {
int tot=;
for(int i=; i<t; ++i)
if(s>>i&)
for(int j=H[q[i]]; j; j=nxt[j])
assert(!H[to[j]]), ++tot;
ans+=pw[t]*(pw[tot]*+(-pw[tot])*);
}
return ans;
}
}
void Subtask3(int Q) {
static int dep[N];
int H=; dep[]=;
while(Q--) {
int opt=read(),x=read();
if(opt==) dep[++n]=++H;
else {
int h=H-dep[x];
double ans=h*pw[h];
for(int i=; i<h; ++i) ans+=i*pw[i+];
printf("%.10lf\n",ans);
}
}
} int main() {
freopen("threebody.in","r",stdin);
freopen("threebody.out","w",stdout); n=;
int T=read(), Q=read(); pw[]=;
for(int i=; i<=Q; ++i) pw[i]=pw[i-]*0.5; if(T==) {Subtask3(Q); return ;} while(Q--) {
int opt=read(),x=read();
if(opt==) AddEdge(x,++n);
else if(T==) printf("%.10lf\n",-pw[sz[x]]);//Subtask2
else printf("%.10lf\n",Calc(x));//Subtask1
}
return ;
}

subtask1.2.3.

#include <cstdio>
#include <cctype>
#include <assert.h>
#include <algorithm>
#define gc() getchar()
#define MAX_H 60
const int N=5e5+; int n,fa[N];
double f[N][MAX_H]; inline int read() {
int now=;register char c=gc();
for(;!isdigit(c);c=gc());
for(;isdigit(c);now=now*+c-'',c=gc());
return now;
} int main() {
freopen("threebody.in","r",stdin);
freopen("threebody.out","w",stdout); n=;
for(int i=; i<MAX_H; ++i) f[][i]=;
for(int T=read(), Q=read(); Q--; ) {
int opt=read(),x=read();
if(opt==) {
fa[++n]=x;
for(int i=; i<MAX_H; ++i) f[n][i]=;
double tmp1=f[x][],tmp2;
f[x][]*=0.5;
for(int Fa=fa[x],i=; Fa&&i<MAX_H; Fa=fa[x=Fa],++i) {
tmp2=f[Fa][i];
f[Fa][i] /= 0.5 + 0.5*tmp1;
f[Fa][i] *= 0.5 + 0.5*f[x][i-];
tmp1=tmp2;
}
}
else {
double ans=; assert(x<=n);
for(int i=; i<MAX_H; ++i) ans+=(f[x][i]-f[x][i-])*i;
printf("%.10lf\n",ans);
}
}
return ;
}

正解

18/9/22NOIP模拟考的更多相关文章

  1. 18.4.09 模拟考 zhx P75

    题目链接 https://files.cnblogs.com/files/lovewhy/P75.pdf P75 竞赛时间: ????年??月??日??:??-??:?? 注意事项(请务必仔细阅读) ...

  2. 18/9/21模拟赛-Updated

    18/9/21模拟赛 期望得分:100:实际得分:0  qwq 拿到题目第一眼,我去,这不是洛谷原题(仓鼠找Sugar)吗 又多看了几眼,嗯,对,除了是有多组数据外,就是原题 然后码码码....自以为 ...

  3. Noip模拟考第三题——饥饿游戏

    饥饿游戏 (hungry.pas/c/cpp) [问题描述] Chanxer饿了,但是囊中羞涩,于是他去参加号称免费吃到饱的“饥饿游戏”. 这个游戏的规则是这样的,举办者会摆出一排 个食物,希望你能够 ...

  4. 2018年小米高级 PHP 工程师面试题(模拟考试卷)

    1.通过哪一个函数,可以把错误转换为异常处理? A:set_error_handler B:error_reporting C:error2exception D:catch 正确答案:A 答案分析: ...

  5. [7.22NOIP模拟测试7]方程的解 题解(扩展欧几里得)

    Orz 送分比较慷慨的一道题,疯狂特判能拿不少分. 对于$a>0,b>0$的情况: 用exgcd求出方程通解,然后通过操作得到最小正整数解和最大正整数解 他们以及他们之间的解满足等差数列性 ...

  6. 6.18 省选模拟赛 树 倍增 LCT

    LINK:树 考虑暴力 保存每个版本的父亲 然后暴力向上跳.得分20. 考虑离线 可以离线那么就可以先把树给搞出来 然后考虑求k级祖先 可以倍增求. 如何判断合法 其实要求路径上的边的时间戳<= ...

  7. 11.12模拟考T1(可持续优化)PS:神奇的东西

    1.数列操作   (array.pas/c/cpp) [问题描述] 现在有一个数列,最初包含0个数.现在要对数列操作n次,操作有3类. 1) a k,在数列的最后插入一个整数k 2) s 将最近插入的 ...

  8. 11.12模拟考T2(GCD)

    2.梅花桩   (blossom.pas/c/cpp) [问题描述] 小x在练习一门轻功,这门轻功是在梅花桩上跳来跳去,这门轻功是严格按照直线从一个梅花桩直接跳到另外一个梅花桩上.因为小x有恐高症,所 ...

  9. 论人品 | | noip1015模拟考

    第一题:火车进站... 由于有了老师给的助攻,第一题的时间为半小时,主要在读题了.... jzoj1146 第二题:car 难在正方形的计算? 第二题时间:1.5hour 第三题:sort排序?

随机推荐

  1. NET Core微服务之路:实战SkyWalking+Exceptionless体验生产下追踪系统

    原文:NET Core微服务之路:实战SkyWalking+Exceptionless体验生产下追踪系统 前言 当一个APM或一个日志中心实际部署在生产环境中时,是有点力不从心的. 比如如下场景分析的 ...

  2. hdu 思维风暴

    点击打开链接 偶然在杭电上看到的题目,数学题.好像是一道六年级奥赛题目,反正我是没有想出来,也知道往那上面想.就是找不到规律啊.学习了网上的方法, 这道题须要求出来多添加的点,就是与之前每条边添加的点 ...

  3. 最全Pycharm教程(10)——Pycharm调试器总篇

    最全Pycharm教程(1)--定制外观 最全Pycharm教程(2)--代码风格 最全Pycharm教程(3)--代码的调试.执行 最全Pycharm教程(4)--有关Python解释器的相关配置 ...

  4. Struts2 全局结果集

    1.index,jsp <body> Result类型 <ol> <li><a href="user/user?type=1">返回 ...

  5. HDU 4372 Count the Buildings 组合数学

    题意:有n个点上可能有楼房,从前面可以看到x栋楼,从后面可以看到y栋,问楼的位置有多少种可能. 印象中好像做过这个题,

  6. 【Codeforces Round #460 (Div. 2) B】 Perfect Number

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直接暴力求出第k个perfect数字就好. 纯模拟. [代码] #include <bits/stdc++.h> #de ...

  7. Python入门:全站url爬取

    <p>作为一个安全测试人员,面对一个大型网站的时候,手工测试很有可能测试不全,这时候就非常需要一个通用型的网站扫描器.当然能直接扫出漏洞的工具也有很多,但这样你只能算是一个工具使用者,对于 ...

  8. 洛谷——P1518 两只塔姆沃斯牛 The Tamworth Two

    https://www.luogu.org/problem/show?pid=1518 题目背景 题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为( ...

  9. SPSS提示“列表中不同意存在字符串变量”的解决方法

    今天用SPSS对一些数据进行主成分分析,SPSS 19.0进行主成分分析的方法是:分析--降维--因子分析,可是当导入一些变量的时候.就会弹出窗体说"列表中不同意存在字符串变量", ...

  10. spring 使用c3po连接池

    1 数据源:能够简单理解为数据的来源. 2 连接池:是缓存一定数量的数据库连接,当程序须要数据库连接的时候,直接在连接池中获取空暇的连接,使用完再放回连接池中,此连接又变成空暇状态,等待下一次连接. ...