Online game is the first three hours past the back of five, and then two hours did not do anything, the account password has been forgotten, had to re-write it again;
hdu-5868
hdu-5869
hdu-5870
hdu-5871
hdu-5872
hdu-5873
hdu-5874
hdu-5875
hdu-5876
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < cmath> #include <bits/stdc++.h> #include <stack> #include <map> using namespace std; #define for (i,j,n) for (int i=j;i<=n;i++) #define MST (SS,B) memset (ss,b,sizeof (ss)); #define LL Long Long;typedef long l Ong LL; Template<class t> void Read (t&num) {char CH; bool F=false; For (Ch=getchar (); ch< ' 0 ' | | Ch> ' 9 '; f= ch== '-', Ch=getchar ()); for (num=0; ch>= ' 0 ' &&ch<= ' 9 '; num=num*10+ch-' 0 ', Ch=getchar ()); F && (num=-num);} int stk[70], tp;template<class t> inline void print (T p) {if (!p) {puts ("0"); return;} while (p) stk[++ TP] = p%10, p/=10; while (TP) Putchar (stk[tp--] + ' 0 '); Putchar (' \ n ');} Const LL Mod=1e9+7;const double Pi=acos ( -1.0); const ll Inf=1e18;const int N=1e6+2000;const int Maxn=2e5+50;const Double EP S=1e-8;int N,M,ANS[MAXN];p air<int,int>p;map<pair<int,int>,int>mp;queue<int>q,qu;inline void Makepair (int u,int v) {p.first=u; P.second=v; Mp[p]=1;} int main () {int t; Read (t); while (t--) {mp.clear (); Read (n); read (m); int u,v,s; for (i,1,m) {read (u); Read (v); Makepair (U,V); Makepair (V,u); } read (s); while (!q.empty ()) Q.pop (); while (!qu.empty ()) Qu.pop (); for (I,1,n) {if (s==i) continue; Qu.push (i); } q.push (s); ans[s]=0; while (!q.empty ()) {int Fr=q.front (); Q.pop (); int siz=qu.size (); P.FIRST=FR; while (siz--) {int F=qu.front (); Qu.pop (); P.second=f; if (!mp[p]) Ans[f]=ans[fr]+1,q.push (f); else Qu.push (f); }} int num=0; for (I,1,n) {if (i==s) continue; num++; if (num<n-1) printf ("%d", ans[i]); else printf ("%d\n", Ans[i]); }} return 0;} /* Test instructions: Ask for a point of a few multilateral small complement map of a starting point to all other points of the shortest distance; train of thought: the side of the map is not the side of the original image, then each time to determine whether there is an edge between the two points in the original image, mainly the original inside the side less can be judged;
hdu-5877
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < cmath> #include <bits/stdc++.h> #include <stack> #include <map> using namespace std; #define for (i,j,n) for (int i=j;i<=n;i++) #define MST (SS,B) memset (ss,b,sizeof (ss)); #define LL Long Long;typedef long l Ong LL; Template<class t> void Read (t&num) {char CH; bool F=false; For (Ch=getchar (); ch< ' 0 ' | | Ch> ' 9 '; f= ch== '-', Ch=getchar ()); for (num=0; ch>= ' 0 ' &&ch<= ' 9 '; num=num*10+ch-' 0 ', Ch=getchar ()); F && (num=-num);} int stk[70], tp;template<class t> inline void print (T p) {if (!p) {puts ("0"); return;} while (p) stk[++ TP] = p%10, p/=10; while (TP) Putchar (stk[tp--] + ' 0 '); Putchar (' \ n ');} Const LL Mod=1e9+7;const double Pi=acos ( -1.0); const ll Inf=1e18;const int N=1e6+2000;const int Maxn=2e5+50;const Double EP S=1e-8;int A[maxn],b[maxn],c[maxn],cnt,sum[maxn],in[maxn],n; LL K,ans;vector<int>ve[maxn];iNT lowbit (int x) {return x& (-X);} inline int query (int x) {int s=0; while (x) {s+=sum[x]; X-=lowbit (x); } return s;} inline void update (int x,int num) {while (x<=cnt) {sum[x]+=num; X+=lowbit (x); }}inline int GetPos (LL x) {int l=1,r=cnt; while (l<=r) {int mid= (L+R) >>1; if (LL) c[mid]>x) r=mid-1; else l=mid+1; } return R;} void dfs (int cur) {int pos; if (a[cur]==0) pos=cnt; else Pos=getpos (K/a[cur]); Ans=ans+query (POS); int Temp=getpos (a[cur]); Update (temp,1); int len=ve[cur].size (); for (int i=0;i<len;i++) DFS (Ve[cur][i]); Update (TEMP,-1);} int main () {int t; Read (t); while (t--) {read (n); read (k); for (i,0,n) {ve[i].clear (); sum[i]=in[i]=0; } for (I,1,n) read (A[i]), b[i]=a[i]; Sort (b+1,b+n+1); c[1]=b[1];cnt=1;ans=0; for (I,2,n) {if (b[i]==b[i-1]) continue; C[++cnt]=b[i]; } int u,v,root; for (i,1,n-1) {read (u); Read (v); Ve[u].push_back (v); in[v]++; } for (I,1,n) {if (in[i]) continue; root=i; Break } dfs (root); print (ANS); } return 0;} /* Test instructions: Ask each node u and its ancestor node V to satisfy the logarithm of a[u]*a[v]<=k; idea: The DFS process keeps the tree array of all its ancestor nodes information, can be discretized after the query, and then the information of this point is more granular into the tree array, After all the nodes have been accessed and then deleted, it is said that Treap can also do;
2016 Dalian Online game