P14450 [ICPC 2025 Xi'an R] Directed Acyclic Graph 题解
题目链接:P14450 [ICPC 2025 Xi'an R] Directed Acyclic Graph
答案构造:

显然只给答案是错误的,解释一下 首先我们发现 $ k>n^2 $,所以考虑构造使得原图的 $ k $ 的大小是指数级的。有一种构造是分上下两层,上层点和下层点两两连边,然后让上下两层点一一匹配,匹配的两个点之间的边断开,这样选取上层点中的任意一个集合,$ f(S) $ 就是 $ S $ 的补集了,因此是 $ 2^n $ 级别的。中间的连边可以使用前后缀优化建图,但是这样的建图需要 $ 3n-6 $ 条额外边,即 $ n $ 最大只能取 $ \lceil \frac{128-100+1+6}{3}\rceil = 11 $,显然 $ 2^11<16000 $。考虑拓展这个构造,令上下两层的层数都为 $ p $ 层,有 $ q $ 列,则 $ k $ 大约是 $ (p+1)^q $,并且需要 $ pq+2q-6 $ 条额外边,取 $ p=3, q=7 $ 的时候符合条件。
代码:
#include<bits/stdc++.h>
#define time(null) chrono::steady_clock::now().time_since_epoch().count()
#define int long long
#define uint unsigned long long
#define debug() cout<<"come here\n"
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pb push_back
#define Code return
#define by 0
#define MCYYDS ;
using namespace std;
int qpow(int a,int b,int p=INF){int ret=1;while(b){if(b&1)ret=(ret*a)%p;a=(a*a)%p;b>>=1;}return ret;}
inline int read(){int ret=0,f=1;char ch=getchar();while(ch<'0'||ch>'9')f=(ch=='-'?-1:f),ch=getchar();while(ch>='0'&&ch<='9')ret=(ret<<3)+(ret<<1)+(ch^48),ch=getchar();return ret*f;}
inline void write(int x){if(x<0){putchar('-');write(-x);return ;}if(x>9)write(x/10);putchar((char)(x%10+48));}
inline void writech(int x,char ch){write(x);putchar(ch);}
signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int n=read(),m=read(),k=read();
if(n==5&&m==6&&k==6)
{
cout<<"1 2\n1 3\n2 4\n3 5\n2 5\n3 4\n1 1\n1 2\n1 3\n1 4\n1 5\n2 2 3\n";
return 0;
}
cout<<2<<' '<<3<<'\n';
cout<<3<<' '<<4<<'\n';
cout<<5<<' '<<6<<'\n';
cout<<6<<' '<<7<<'\n';
cout<<8<<' '<<9<<'\n';
cout<<9<<' '<<10<<'\n';
cout<<11<<' '<<12<<'\n';
cout<<12<<' '<<13<<'\n';
cout<<14<<' '<<15<<'\n';
cout<<15<<' '<<16<<'\n';
cout<<17<<' '<<18<<'\n';
cout<<18<<' '<<19<<'\n';
cout<<20<<' '<<21<<'\n';
cout<<21<<' '<<22<<'\n';
cout<<1<<' '<<2<<'\n';
cout<<1<<' '<<5<<'\n';
cout<<1<<' '<<8<<'\n';
cout<<1<<' '<<11<<'\n';
cout<<1<<' '<<14<<'\n';
cout<<1<<' '<<17<<'\n';
cout<<1<<' '<<20<<'\n';
cout<<23<<' '<<24<<'\n';
cout<<24<<' '<<25<<'\n';
cout<<25<<' '<<26<<'\n';
cout<<26<<' '<<27<<'\n';
cout<<27<<' '<<28<<'\n';
cout<<4<<' '<<23<<'\n';
cout<<7<<' '<<24<<'\n';
cout<<10<<' '<<25<<'\n';
cout<<13<<' '<<26<<'\n';
cout<<16<<' '<<27<<'\n';
cout<<19<<' '<<28<<'\n';
cout<<22<<' '<<29<<'\n';
cout<<19<<' '<<30<<'\n';
cout<<16<<' '<<31<<'\n';
cout<<13<<' '<<32<<'\n';
cout<<10<<' '<<33<<'\n';
cout<<7<<' '<<34<<'\n';
cout<<29<<' '<<30<<'\n';
cout<<30<<' '<<31<<'\n';
cout<<31<<' '<<32<<'\n';
cout<<32<<' '<<33<<'\n';
cout<<33<<' '<<34<<'\n';
cout<<35<<' '<<36<<'\n';
cout<<36<<' '<<37<<'\n';
cout<<38<<' '<<39<<'\n';
cout<<39<<' '<<40<<'\n';
cout<<41<<' '<<42<<'\n';
cout<<42<<' '<<43<<'\n';
cout<<44<<' '<<45<<'\n';
cout<<45<<' '<<46<<'\n';
cout<<47<<' '<<48<<'\n';
cout<<48<<' '<<49<<'\n';
cout<<50<<' '<<51<<'\n';
cout<<51<<' '<<52<<'\n';
cout<<53<<' '<<54<<'\n';
cout<<54<<' '<<55<<'\n';
cout<<29<<' '<<50<<'\n';
cout<<30<<' '<<47<<'\n';
cout<<31<<' '<<44<<'\n';
cout<<32<<' '<<41<<'\n';
cout<<33<<' '<<38<<'\n';
cout<<34<<' '<<35<<'\n';
cout<<28<<' '<<53<<'\n';
cout<<27<<' '<<50<<'\n';
cout<<26<<' '<<47<<'\n';
cout<<25<<' '<<44<<'\n';
cout<<24<<' '<<41<<'\n';
cout<<23<<' '<<38<<'\n';
cout<<2<<' '<<36<<'\n';
cout<<3<<' '<<37<<'\n';
cout<<5<<' '<<39<<'\n';
cout<<6<<' '<<40<<'\n';
cout<<8<<' '<<42<<'\n';
cout<<9<<' '<<43<<'\n';
cout<<11<<' '<<45<<'\n';
cout<<12<<' '<<46<<'\n';
cout<<14<<' '<<48<<'\n';
cout<<15<<' '<<49<<'\n';
cout<<17<<' '<<51<<'\n';
cout<<18<<' '<<52<<'\n';
cout<<20<<' '<<54<<'\n';
cout<<21<<' '<<55<<'\n';
for(int i=56;i<=100;i++)
{
cout<<1<<' '<<i<<'\n';
}
for(int i=1;i<=16000;i++)
{
vector<int> cur;
for(int j=0;j<7;j++)
{
int mask=((i>>(j*2))&3);
if(mask)cur.pb(j*3+mask+1);
}
writech(cur.size(),' ');
for(auto x:cur)
{
writech(x,' ');
}
puts("");
}
Code by MCYYDS
}

浙公网安备 33010602011771号