"2019.7.29 exam" What people can not give up what can not be changed

  Overall it is more of a test failure, died just two and a half hours T1, the remaining less than forty minutes to write T3, very short, and burst 0. Resulting in uneven distribution serious time T3 although the thought of some solution but did not have time to implement and debug.

  Probably the examination process is to look at the three questions, find T3 is very simple, and then began to think, three minutes seconds off the formula, about 7:22 when he cut off (it turns out that in addition to a special sentence indeed cut off, and seven minutes before the opening test I looked at the table). Then go back to see the first question, divided into two halves contribution was found between the rectangle inside the rectangle and the inner rectangle may be $ O (1) $ obtained, the rectangle may be between $ O (n ^ 2) $ calculated, but not strictly $ O (n ^ 2) $, because between the rectangular Pro edge little, not when he jumped on it. The results can not write for twenty minutes too large a sample was desperate, when debugging found that the smaller the value the more rectangular me very puzzled, but ultimately did not tune out (actually rectangular boundary treatment is a problem, there has been a negative ). So do T2, the second is the basic solution (although not perfect, but almost essential and positive solutions, in addition to the merger), and then ten minutes knocked two trees began to maintain, just over a small sample, or big trouble, has been transferred to the end of the exam, so happy T3 burst 0.

  The following is a solution to a problem, but if this thing is not the most important achievement of this examination, I think it should shed some light on the mentality, which I would say at last.

T1:

  Points are really violent and no level I too lazy to write .

  Contribution in two parts,

  Internal Contribution = $ 2 (x2-x1) (y2-y1) $

  Contribution = $ 2 boundary (boundary length) + [end coordinate is not the same] + [the other end of the coordinate is not the same] $

  Violence enumeration can add up to no boundaries when you can swap $ break $

 

T2:

  Relatively strong a question, think of the examination room timeline achievements, think of a few binary search top $ size $ $ k $, think of the merger (fake tree line merger, the merger should be heuristic).

  Like a long time there has been no result, because I do not traverse the tree line is merging all nodes to the complexity of the security, but after the merger can not be determined yet what point is a contribution, it makes me very uncomfortable, I finally took the violence method, check the violence which node is double counting, the contribution is set to 0, but will repeat the calculation, for example, has been calculated useless in a sub-tree when a certain time, then the next sub-tree of the merger process he never continue to be useful, then you can not check, but I did not think of it on the test, so maybe I can save a dead tree line merge ideas.

  The rest is a heuristic merged. What does the merger? We do not merge tree line, the merge operation, perhaps you think this is very violent, but he has a certain complexity guarantee $ (O (nlog_2n)) $.

  Heuristic merger is actually very simple, is to put a small stuffed inside large, so if you can make to minimize the cost, complexity, how come? Suppose we complexity of each merger is $ (O (n)) $, and the worst case is that every time I take a big stuffed like you and you, so every time I doubled, that is, to increase (log_2n) $ times, then the total complexity is $ O (nlog_2n) $ $

  Complexity is guaranteed, then how to merge it? Consider the trees "large" mean. Decadent a very detailed explanations will understand. Yes, it's heavy son. Heavy your son is the largest sub-tree, the other sub-tree after the process is completed directly online segment tree marking can be removed, and heavy son must not be deleted because you want to establish operations operate on the basis of weight on his son that could ensure that complexity.

  I did not expect to maintain such a violent way tree line. . .

  His own son's re-insertion operations $ vector $ (re-son operation to be more than me, after all I have a node in general) and then switching position, then the other light into my son's operation $ vector $, so the completion of a number of heuristics merger, the complexity of the guarantee is $ O (nlog_2n) $.

  Just suddenly thought for a moment, the severity of division should not be to the point as the byte size division basis, and should be used $ vector $ child node size, he was almost a $ 100ms $.

  And each operation corresponding to the segment tree was last modified or deleted.

  The total complexity is $ (nlog_2 ^ 2n) O $

  This process is carried out every recursively, this question can be the perfect solution.

  He said relatively sloppy, do not understand the comments section.

  

  1 #include<cstdio>
  2 #include<cmath>
  3 #include<vector>
  4 #include<iostream>
  5 #include<map>
  6 using namespace std;
  7 const int maxn=1e5+5,INF=0x3f3f3f3f;
  8 map<int,int> mp;
  9 vector<int> bl[maxn],dr[maxn];
 10 int n,m,q,cnt,tot,x,y,a[maxn],first[maxn],ans[maxn],sz[maxn],son[maxn],t[maxn];
 11 struct road{
 12     int u,t,nxt;
 13 }eage[maxn<<1];
 14 void add(int x,int y)
 15 {
 16     eage[++tot].u=x;
 17     eage[tot].t=y;
 18     eage[tot].nxt=first[x];
 19     first[x]=tot;
 20 }
 21 struct SegmentTree{
 22     int tot,data[maxn<<2],sz[maxn<<2],f[maxn<<2];
 23     void FoundData(int x)
 24     {
 25         data[x]=data[x<<1]+data[x<<1|1];
 26         sz[x]=sz[x<<1]+sz[x<<1|1];
 27     }
 28     void LazyDown(int x)
 29     {
 30         if(!f[x]) return ;
 31         f[x<<1]=f[x<<1|1]=1;
 32         data[x<<1]=data[x<<1|1]=sz[x<<1]=sz[x<<1|1]=0;
 33         f[x]=0;
 34     }
 35     void Updata(int x,int l,int r,int p,int d,int num)
 36     {
 37         data[x]+=d;sz[x]+=num;
 38         if(l==r) return ;
 39         int mid=(l+r)>>1;
 40         LazyDown(x);
 41         if(p<=mid) Updata(x<<1,l,mid,p,d,num);
 42         else Updata(x<<1|1,mid+1,r,p,d,num);
 43         FoundData(x);
 44     }
 45     void Sectiondin(int x)
 46     {
 47         data[x]=sz[x]=0;f[x]=1;
 48     }
 49     int SectionQuery(int x,int l,int r,int sum)
 50     {
 51     //    cout<<l<<" "<<r<<"==="<<sz[x]<<" "<<data[x]<<" "<<sum<<endl;
 52         if(sum<=0) return 0;
 53         if(l==r) return data[x];
 54         int mid=(l+r)>>1,ans=0;
 55         LazyDown(x);
 56         if(sz[x<<1]<=sum)
 57         {
 58             ans+=data[x<<1];
 59             ans+=SectionQuery(x<<1|1,mid+1,r,sum-sz[x<<1]);
 60             return ans;
 61         }
 62         else return SectionQuery(x<<1,l,mid,sum);
 63     }
 64     void init(int x)
 65     {
 66     //    cout<<x<<"##init"<<endl;
 67         for(int i=0;i<bl[x].size();i++)
 68         {
 69             int col=bl[x][i],r=dr[x][i];
 70     //        cout<<col<<" "<<sz[1]<<endl;
 71             if(!t[col]) Updata(1,1,m,r,1,0),t[col]=r;
 72             else if(t[col]>r)
 73             {
 74                 Updata(1,1,m,t[col],-1,0);
 75                 Updata(1,1,m,r,1,0);
 76                 t[col]=r;
 77             }
 78             Updata(1,1,m,r,0,1);
 79         }
 80     }
 81     void dinit(int x)
 82     {
 83         Sectiondin(1);
 84         for(int i=0;i<bl[x].size();i++) t[bl[x][i]]=0;
 85     }
 86 }zt;
 87 void insert(int x,int y)
 88 {
 89     for(int i=0;i<bl[y].size();i++)
 90     {
 91         bl[x].push_back(bl[y][i]);
 92         dr[x].push_back(dr[y][i]);
 93     }
 94     bl[y].clear();dr[y].clear();
 95 }
 96 void dfs1(int x,int fa)
 97 {
 98     sz[x]=bl[x].size();
 99     for(int i=first[x];i;i=eage[i].nxt)
100         if(eage[i].t!=fa)
101         {
102             dfs1(eage[i].t,x);
103             sz[x]+=sz[eage[i].t];
104             if(sz[son[x]]<sz[eage[i].t]) son[x]=eage[i].t;
105         }
106 }
107 void dfs(int x,int fa)
108 {
109     for(int i=first[x];i;i=eage[i].nxt)
110         if(eage[i].t!=fa&&eage[i].t!=son[x])
111         {
112             dfs(eage[i].t,x);
113             zt.dinit(eage[i].t);
114         }
115     if(son[x]) dfs(son[x],x);
116     zt.init(x);
117     for(int i=first[x];i;i=eage[i].nxt)
118         if(eage[i].t!=fa&&eage[i].t!=son[x])
119             zt.init(eage[i].t);
120 //    cout<<x<<":"<<endl;
121 ans[x]=zt.SectionQuery(1,1,m,a[x]);
122     if(son[x])
123     {
124         insert(son[x],x);
125         swap(bl[son[x]],bl[x]);
126         swap(dr[son[x]],dr[x]);
127         for(int i=first[x];i;i=eage[i].nxt)
128             if(eage[i].t!=fa)
129                 insert(x,eage[i].t);
130     }
131 }
132 int main()
133 {
134     scanf("%d",&n);
135     for(int i=1;i<n;i++)
136     {
137         scanf("%d%d",&x,&y);
138         add(x,y);add(y,x);
139     }
140     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
141     scanf("%d",&m);
142     for(int i=1;i<=m;i++)
143     {
144         scanf("%d%d",&x,&y);
145         if(mp[y]==0) mp[y]=++cnt,y=cnt;
146         else y=mp[y];
147         bl[x].push_back(y);
148         dr[x].push_back(i);
149     }
150     sz[0]=-1;
151     dfs1(1,0);
152     dfs(1,0);
153     scanf("%d",&q);
154     while(q--)
155     {
156         scanf("%d",&x);
157         printf("%d\n",ans[x]);
158     }
159     return 0;
160 }
ac

 

 

 

T3:

  说实话真的很水,三分钟秒掉式子。大概说一下。

  设$dp[i][j]$为前$i$题最高难度为$j$的概率,$w[i]$为每种难度的劳累值。

  初始化:

    $dp[0][0]=1$

  转移:

    $dp[i][j]=inv_m(\sum  \limits_{k=0}^j dp[i-1][k]+(j-1)dp[i-1][j])$

  解释一下,我当前的最大难度是$j$的可能性有两个:

  1.我之前某些点或者达到或者没达到,但是在我这里都达到了,也就有了前面那个$\sum$

  2.我之前某些点达到了而我没有达到,那就是我有$(j-1)$种情况,所以乘上$(j-1)$。

然后就切掉了。

 

下面说些心态的问题:

  我当时秒切T3觉得自己可厉害了可厉害了我心想这次稳了啊,爷要AK了啊,结果结果还是T1一调不出来心态就崩了,心想我怎么就调不出来。

  心态这个东西很微妙,你永远不知道他怎么调整或者有什么影响。我之前能做到的是考前不对这次考试报任何希望,可是在答题过程中却犯了这些禁忌,期望过高了,导致一但有什么波折就死心态。如果你是真的强三道题都全秒掉的话其实也没啥问题,但是我这种一般人做不到全秒,而且喜欢自负的觉得自己能做到全秒。虽然真的基本都正解了,可是还是能力不足没有拿到分数。

  那再立个$flag$下次要做到的是不在考前有任何期望,不再考试的时候有任何期望,心如止水。

  还有另外一个东西叫舍得。

  有舍才有得,考场上很多东西都要懂得取舍,不是文化课那两下子,直接从头做就行了的,可能丢失掉这一部分会换来更大的成绩,这时候应当不再优柔寡断,不要在侥幸的以为在过五分钟你就能调出来,事实上到考试结束你也调不出来。舍得出去才能有得到,这是毋庸置疑的,考场上就那么多时间,拿到做多得分是最重要的,而不是去作出一道你耗费了大量心血或者一眼正解的题,没有意义,这是考试不是刷题,刷题刷一天也没人管你,但考试就三个半钟头,考的出来是他,考不出来也是他了。

  但是有时候并非有舍一定会有得,可能舍弃的是一个重要的作出某道题机会。但是考场时间非常紧迫,不管对错的选择,都没有时间回头想。

  为自己的选择决定,决定了就去做,为决定负责,即使即将要为他后悔,在所不辞。

  什么都无法舍弃的人什么也无法改变。

  想起来之前看到的一句话,虽然没什么关系,但至少教会你负责任。

  

  你是个小人物,一生难得做几件大事,这个机会很宝贵。死一个人不要紧,自己死了也不要紧。你可以偶尔发个疯,可是有些事不能逃避,该做的事情必须要做,树要开花,人要长大。       

                                       ——江洋

 

以上。

Guess you like

Origin www.cnblogs.com/Lrefrain/p/11267557.html