A.
Test instructions: Given a sequence, you can add any number of them to the integer multiples of K, after which the sequence needs to be changed from small to large rows 1,2,3,4,5,6
Answer: The most intuitive method is a match, but think 500*100*100*100 may be super-
But you can see that A can change to B when a%k = = B%k && A <= K
Then we'll have a priority queue for every possible remainder, sweep it all over again.
You're going to be a fool for yourself, Qaq.
Break out Qaq When you're done emptying.
#include <cstdio>#include<iostream>#include<cstring>#include<Set>#include<queue>using namespacestd;Const intN = the; typedefstructnode{intxi,v; BOOL operator< (ConstNode &a)Const{ if(xi = = A.XI)returnV <A.V; Else returnXi >A.xi; }}node;node NewNode (intXinty) {node tmp; Tmp.xi=x; TMP.V=y; returntmp;}intn,m,k;intA[n],b[n],tmpa[n],tmpb[n]; priority_queue<node>Q[n];intMain () {intT CIN >>T; while(t--) {cin>> N >>K; for(inti =1; I <= n;i++) scanf ("%d",&A[i]); for(inti =1; I <= n;i++) b[i] =i; for(inti =1; I <= n;i++) Q[a[i]%k].push (NewNode (a[i),1)); for(inti =1; I <= n;i++) Q[b[i]%k].push (NewNode (b[i],-1)); intFlag =0;intCNT =0; for(intt =0; t < k;t++,cnt =0){ while(!(Q[t].empty ())) {Node U=Q[t].top (); Q[t].pop (); CNT+=U.V; if(CNT <0) flag =1; } if(CNT! =0) flag =1; } if(flag) printf ("tom\n"); Elseprintf"jerry\n"); } }
ACM-ICPC Shanghai 2014