版本比较
2017-2018 ACM-ICPC, Asia Daejeon Regional Contest 题解
正文
增加 21 行删除 21 行
41 行未改动42434445464746474849505171 行未改动1231241251261271271281291301311321331341341351361371381391401411421431431441451461471481491501511521521531541551561571581591591601611621631641651661671681671681691701711726 行未改动17918018118218318318418518618713 行未改动201202203204205205206207208209171 行未改动全部展开3813823833843853853863873883895 行未改动39539639739839939940040140240353 行未改动45745845946046146146246346446587 行未改动55355455555655755755855956056111 行未改动573574575576577577578579580581161 行未改动全部展开74374474574674774774874975075122 行未改动77477577677777877877978078178295 行未改动878879880881882882883884885886887888889890891892892893894895896897898899899900901902903161 行未改动全部展开41 行未改动using namespace std;const int mxn=5005;int n;vector<int>G[mxn];int f[mxn][mxn];//f[i][j]表示考虑到以i为根的子树 向上覆盖k层的最小代价 int g[mxn][mxn];//g[i][j]表示考虑到以i为根的子树 j层以下的都能被覆盖的最小代价 int f[mxn][mxn];//f[i][j]表示考虑到以i为根的子树 向上覆盖k层的最小代价int g[mxn][mxn];//g[i][j]表示考虑到以i为根的子树 j层以下的都能被覆盖的最小代价inline void dfs(int u,int fa=0){ for(int i=0;i<=n;++i)f[u][i]=g[u][i]=n; vector<int>sum;sum.clear(); for(int i=0;i<=n+1;++i)sum.push_back(0);71 行未改动 if(v[i][0]==2 and v[i][1]==2 and v[i][2]==2)return 2; if(v[i][3]==1 and v[i][1]==1 and v[i][2]==1)return 1; if(v[i][3]==2 and v[i][1]==2 and v[i][2]==2)return 2; }
for(int j=0;j<4;++j){ if(v[0][j]==1 and v[1][j]==1 and v[2][j]==1)return 1; if(v[0][j]==2 and v[1][j]==2 and v[2][j]==2)return 2; if(v[3][j]==1 and v[1][j]==1 and v[2][j]==1)return 1; if(v[3][j]==2 and v[1][j]==2 and v[2][j]==2)return 2; }
if(v[0][0]==1 and v[1][1]==1 and v[2][2]==1)return 1; if(v[0][0]==2 and v[1][1]==2 and v[2][2]==2)return 2; if(v[3][3]==1 and v[1][1]==1 and v[2][2]==1)return 1; if(v[3][3]==2 and v[1][1]==2 and v[2][2]==2)return 2; if(v[1][0]==1 and v[2][1]==1 and v[3][2]==1)return 1; if(v[1][0]==2 and v[2][1]==2 and v[3][2]==2)return 2; if(v[0][1]==1 and v[1][2]==1 and v[2][3]==1)return 1; if(v[0][1]==2 and v[1][2]==2 and v[2][3]==2)return 2;
if(v[0][2]==1 and v[1][1]==1 and v[2][0]==1)return 1; if(v[0][2]==2 and v[1][1]==2 and v[2][0]==2)return 2; if(v[1][3]==1 and v[2][2]==1 and v[3][1]==1)return 1; if(v[1][3]==2 and v[2][2]==2 and v[3][1]==2)return 2; if(v[0][3]==1 and v[1][2]==1 and v[2][1]==1)return 1; if(v[0][3]==2 and v[1][2]==2 and v[2][1]==2)return 2; if(v[3][0]==1 and v[1][2]==1 and v[2][1]==1)return 1; if(v[3][0]==2 and v[1][2]==2 and v[2][1]==2)return 2;
return 0;}inline void dfs(int state,int turn){ if(been[state])return; been[state]=1; vector<vector<int> >v=reget(state); if(win(v)==1)return; if(win(v)==1)return; if(v[a][b]){ if(turn==1 and v[a][b]==2 and win(v)==2){ ++ans;// cerr<<"---------------------------\n";// for(int i=0;i<4;++i){// for(int j=0;j<4;++j)cerr<<v[i][j]<<' ';// cerr<<'\n';// } } // } } return; } if(win(v)==2)return; for(int i=0;i<4;++i){6 行未改动 } } }}inline void solve(){ inline void solve(){ int x; cin>>x>>a>>b; --x,--a,--b; swap(a,b);13 行未改动}```---
## Problem C.Game Map ## Problem C.Game Map
通过队伍数:86/107
题目大意:171 行未改动全部展开struct edge{ll to,cap,rev;};vector<edge>g[mxn];inline void add_edge(ll from,ll to,ll cap){ g[from].push_back((edge){to,cap,g[to].size()}); g[to].push_back((edge){from,cap,g[from].size()-1});//无向图 g[to].push_back((edge){from,cap,g[from].size()-1});//无向图}ll iter[mxn],lev[mxn];const ll inf=21474836477777;inline void bfs(){5 行未改动 edge&e=g[p][i]; if(e.cap>0 and lev[e.to]<0){ lev[e.to]=lev[p]+1; q.push(e.to); } } } }}inline ll dfs(ll v,ll t,ll f){53 行未改动```
---
## Problem F.Philosopher’s Walk ## Problem F.Philosopher’s Walk
通过队伍数:74/107
题目大意:87 行未改动struct node{ ll x,y,t;}p[mxn];ll n,m,nn,mm,lst=-1,pre,k;inline bool cmp(node x,node y){return x.x<y.x;} inline bool cmp(node x,node y){return x.x<y.x;}inline void solve(){ cin>>n>>m; cin>>nn;for(int i=0;i<n;++i)cin>>p[i].x>>p[i].y,p[i].t=0; cin>>mm;for(int i=0;i<m;++i)cin>>p[i+n].x>>p[i+n].y,p[i+n].t=1;11 行未改动 if(nn<mm and f)lst=x; else if(nn>=mm and !f){ if(lst>=0){ ++cnt; //同理 因为要求的是封闭多边形 ans+=sum; ans+=sum; } sum=0; lst=x; }161 行未改动全部展开](https://www.luogu.com.cn/problem/P3375)
它是干什么用的?
求 $border$: 求 $border$:
定义一个字符串 $s$ 的 $border$ 为 $s$ 的一个非 $s$ 本身的子串 $t$,满足 $t$ 既是 $s$ 的前缀,又是 $s$ 的后缀。
然后题目怎么转化到这玩意上来?22 行未改动}inline void solve(){ cin>>n; for(int i=0;i<n;++i)cin>>a[i]; reverse(a,a+n);//很显然后面的一定呈循环状 倒过来处理就很方便 reverse(a,a+n);//很显然后面的一定呈循环状 倒过来处理就很方便 kmp(); int ak=n-1,ap=1; for(int i=0;i<=n;++i){ //枚举k int tp=i-nxt[i],tk=n-i;95 行未改动 } } if(dist[t]==INF) return res; int d=19260817; int d=19260817; for(int v=t;v!=s;v=prevv[v]) d=min(d,G[prevv[v]][preve[v]].cap); res+=d; for(int v=t;v!=s;v=prevv[v]){ edge &e=G[prevv[v]][preve[v]]; e.cap-=d; G[v][e.rev].cap+=d; } }}int n,m,a[5053],b[5053]; }int n,m,a[5053],b[5053];int main(){ cin>>n>>m; for(int i=0;i<m;i++){ scanf("%d%d",a+i,b+i); a[i]--;b[i]--; }V=2*n; srand(time(NULL)); srand(time(NULL)); for(int i=0;i<n;i++){ int j,cnt=10; while(cnt--){ j=rand()%(n-i)+i;161 行未改动全部展开