爆零了!

菜爆了

弱展了


垃爆了

没有什么可以掩饰你的菜了

这次考试为我带来了第一个 \(\color{red}{ \huge{0}}\) 分,十分欣慰。。。。

最近的暴力都打不对,你还想什么正解???

考完之前就差不多知道自己大概是一个零分,然而抱着侥幸打开赛时排行榜的时候,直接翻到最下方就直接看到了自己的名字。。。。

无 \(fa\) 可说。。

自己看题都看不全,谁告诉过你 题目背景 就一定没有用了???

然而 \(sb\;XIN\) 直接跳过,并且默认无向图。。。

\(\huge{\text{你不爆零谁爆零?}}\)

T2 贪心都打不对,真垃。

\(\huge{\text{你不爆零谁爆零?}}\)

T3 打的都不配叫做爆搜。

\(\huge{\text{你不爆零谁爆零?}}\)

菜就是了。。。

世界线:

\(bitset\) + \(toposort\)。

就这?

就这。。

\(bitset\) 常数极小,其实平常的 \(bool\) 数组都可以换成 \(bitset\)。

然后 \(toposort\) 就很普通



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define debug cout<<"debug"<<endl
#define int long long
namespace xin_io
{
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
#define scanf eat1 = scanf
#define freopen eat2 = freopen
int eat1; FILE *eat2; char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
template<class type>inline type get()
{
type s = 0,f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io; static const int maxn = 6e4+50,maxm = 1e6+10,inf = 0x7f7f7f,mod = (1<<30);
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
typedef long long ll;
namespace xin
{
int l,r,an[maxn];
class xin_edge{public:int next,ver;}edge[maxm];
int head[maxn],zhi = 0;
inline void add(int x,int y) {edge[++zhi].ver = y;edge[zhi].next = head[x]; head[x] = zhi;}
int n,m;
int ou[maxn];
int outd[maxn],num[maxn];
bool vis[maxn];
int ret = 0;
std::bitset<(maxn/20)>lian[maxn];
int ans = 0,ind[maxn];
inline void topo()
{
std::queue<int>q;
try(i,1,n) if(!outd[i]) q.push(i);//,cout<<"i = "<<i<<endl;;
while(!q.empty())
{
register int x = q.front(); q.pop();
if(x>=l and x<=r)lian[x][(x-l)] = 1;
for(register int i=head[x];i;i=edge[i].next)
{
register int y = edge[i].ver;
if(x>=l and x<=r)lian[x][(x-l)] = 1;
lian[y] |= lian[x];
if(y>=l and y<=r)lian[y][(y-l)] = 1;
outd[y]--;
if(!outd[y]) q.push(y);
}
}
try(i,1,n)an[i] += lian[i].count();
}
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
n = get<signed>(); m = get<signed>();
try(i,1,m)
{
register int x = get<signed>(),y = get<signed>();
add(y,x);ou[x]++; outd[x]++; ind[y]++;
}
l=1;r=std::min(3000ll,n);
while(l<=n)
{
try(i,1,n) lian[i] = 0;
topo();
try(i,1,n)outd[i]=ou[i];
l=r+1,r=std::min(l+3000ll-1,n);
}
try(i,1,n)
ans += an[i] - ind[i];
cout<<ans - n<<endl;
return 0;
}
}
signed main() {return xin::main();}

时间机器:

一个大贪心。

然而你却看不出来。

一个 \(\mathcal O(n^2)\) 暴力狂扫直接 \(70pts\)

然后进一步 \(map\) 优化直接 \(100pts\)

真垃。



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define debug cout<<"debug"<<endl
#define int long long
namespace xin_io
{
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2) ? EOF : *p1++
#define scanf eat1 = scanf
#define freopen eat2 = freopen
int eat1; FILE *eat2; char buf[1<<20],*p1 = buf,*p2 = buf;
inline void openfile() {freopen("t.txt","r",stdin);} inline void outfile() {freopen("o.txt","w",stdout);}
template<class type>inline type get()
{
type s = 0,f = 1; register char ch = gc();
while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = gc();}
return s * f;
}
}
using namespace xin_io; static const int maxn = 1e6+10,maxq = 3e5+10,inf = 0x7f7f7f7f;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
typedef long long ll;
namespace xin
{
int T,n,m;
class node
{
public:
ll l,r,cnt,op;
friend bool operator < (const node &a,const node &b)
{return (a.l==b.l)?a.op<b.op:a.l<b.l;}
}t[maxn];
std::map<ll,ll> mp;
std::map<ll,ll>::iterator it;
inline short main()
{
T = get<signed>();
while(T--)
{
n = get<signed>();m = get<signed>();
mp.clear();
ll cnt=0;
try(i,1,n) t[++cnt].l=get<signed>(),t[cnt].r=get<signed>(),t[cnt].cnt=get<signed>(),t[cnt].op=1;
try(i,1,m) t[++cnt].l=get<signed>(),t[cnt].r=get<signed>(),t[cnt].cnt=get<signed>(),t[cnt].op=-1;
int ok=1;
std::sort(t+1,t+1+cnt);
try(i,1,cnt)
{
//printf("t.op=%lld\n",t[i].op);
if(t[i].op==-1)
mp[t[i].r]+=t[i].cnt;
else
{
while(t[i].cnt)
{
it=mp.lower_bound(t[i].r);
// printf("mp[%lld]=%lld\n",t[i].r,mp[t[i].r]);
if(it==mp.end()) {ok = 0;break; }
if(t[i].cnt >= it->second) t[i].cnt -= it->second,mp.erase(it);
else it->second-=t[i].cnt,t[i].cnt = 0;
}
if(!ok)break;
}
}
!ok ? printf("No\n") : printf("Yes\n");
}
return 0;
}
}
signed main() {return xin::main();}

weight:

首先最小生成树那就先求出来一个。

然后 \(tarjan\) 判断割边就有很多分数。

然后树剖线段树维护就可以 \(\mathcal O(nlogn^2)\)

然而调不出来

[考试总结]noip模拟17的更多相关文章

  1. 6.17考试总结(NOIP模拟8)[星际旅行·砍树·超级树·求和]

    6.17考试总结(NOIP模拟8) 背景 考得不咋样,有一个非常遗憾的地方:最后一题少取膜了,\(100pts->40pts\),改了这么多年的错还是头一回看见以下的情景... T1星际旅行 前 ...

  2. NOIP模拟17.9.21

    NOIP模拟17.9.21 3 58 145 201 161.5 样例输出21.6 数据规模及约定对于40% 的数据,N <= 20对于60% 的数据,N <= 1000对于100% 的数 ...

  3. NOIP模拟17.9.22

    NOIP模拟17.9.22 前进![问题描述]数轴的原点上有一只青蛙.青蛙要跳到数轴上≥

  4. NOIP模拟 17.8.20

    NOIP模拟17.8.20 A.阶乘[题目描述]亲爱的xyx同学正在研究数学与阶乘的关系,但是他喜欢颓废,于是他就制作了一个和阶乘有关系的数学游戏:给出两个整数 n,m,令 t = !n,每轮游戏的流 ...

  5. NOIP模拟 17.8.18

    NOIP模拟17.8.18 A.小菜一碟的背包[题目描述]Blice和阿强巴是好朋友但萌萌哒Blice不擅长数学,所以阿强巴给了她一些奶牛做练习阿强巴有 n头奶牛,每头奶牛每天可以产一定量的奶,同时也 ...

  6. NOIP模拟 17.8.15

    NOIP模拟17.8.15 A 债务文件名 输入文件 输出文件 时间限制 空间限制debt.pas/c/cpp debt.in debt.out 1s 128MB[题目描述]小 G 有一群好朋友,他们 ...

  7. NOIP模拟 17.8.17

    NOIP模拟17.8.17 A 小 G 的字符串文件名 输入文件 输出文件 时间限制 空间限制str.pas/c/cpp str.in str.out 1s 128MB[题目描述]有一天,小 L 给小 ...

  8. NOIP模拟 17.8.16

    NOIP模拟17.8.16 A 债务文件名 输入文件 输出文件 时间限制 空间限制debt.pas/c/cpp debt.in debt.out 1s 128MB[题目描述]小 G 有一群好朋友,他们 ...

  9. NOIP模拟 17.8.14

    NOIP模拟17.8.14 (天宇哥哥考察细心程度的题) [样例解释]如果删去第一个 1:在[3,1,2]中有 3 个不同的数如果删去 3:在[1,1,2]中有 2 个不同的数如果删去第二个 1:在[ ...

随机推荐

  1. Qt中的布局浅析与弹簧的使用,以及Qt居中的两种方法

    1. 布局 为什么要布局: 布局之后窗口的排列是有序的 布局之后窗口的大小发生变化, 控件的大小也会对应变化 如果不对控件布局, 窗口显示出来之后有些控件的看不到的 布局是可以嵌套使用 常用的布局方式 ...

  2. P1123 取数游戏

    题目描述 一个N \times MN×M的由非负整数构成的数字矩阵,你需要在其中取出若干个数字,使得取出的任意两个数字不相邻(若一个数字在另外一个数字相邻88个格子中的一个即认为这两个数字相邻),求取 ...

  3. 【NX二次开发】点到矢量或直线的垂点

    已知p1.p2.v1求p0 求解: 通过P1点和P2点,先求出v2: 使用 UF_VEC3_dot(),v1点乘v2得到P0与P2之间的距离: 使用UF_VEC3_unitize()将v1单位化: p ...

  4. Java基础篇(JVM)——字节码详解

    这是Java基础篇(JVM)的第一篇文章,本来想先说说Java类加载机制的,后来想想,JVM的作用是加载编译器编译好的字节码,并解释成机器码,那么首先应该了解字节码,然后再谈加载字节码的类加载机制似乎 ...

  5. 图的存储与遍历C++实现

    1.图的存储 设点数为n,边数为m 1.1.二维数组 方法:使用一个二维数组 adj 来存边,其中 adj[u][v] 为 1 表示存在 u到 v的边,为 0 表示不存在.如果是带边权的图,可以在 a ...

  6. JS replace 替换全部数据

    (1)使用具有全局标志g的正则表达式 var str = "dogdogdog"; var str2 = str.replace(/dog/g,"cat");/ ...

  7. COURSES 赤裸裸的二分匹配大水题

    COURSES 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include ...

  8. 尝试用面向对象思维理解Vue组件

    什么是组件 用面向对象的思维去理解Vue组件,可以将所有的事物都抽象为对象,而类或者说是组件,都具有属性和操作. 如抽取人类为组件,其基本的属性有姓名.年龄.国籍:基本的方法有吃饭.睡觉.跑步等. & ...

  9. git分支案例

  10. phpCOW机制(写时复制)

    写时复制(Copy-on-Write,也缩写为COW),顾名思义,就是在写入时才真正复制一份内存进行修改. COW最早应用在*nix系统中对线程与内存使用的优化,后面广泛的被使用在各种编程语言中,如C ...