Common Board2^8 queries are given. Each query has an interval [L,R). (2^63<L,R<2^64) Find the number of primes in each interval. P.S. Warning: you won't fit into a hundred lines of code! 2 0 1 2 1 1 1 ------- unknown unknown unknown 1 or 1 1 1 1 Before first visit pub #1 is asking about drinks? unknown unknown unknown 1 Beacuse he doesn't know whether he drank 1 or 0 cocktails last time. And, yes, he will be asked first time. That also means that the trip doesn't stop when answer is unknown Test: 10 2 3 2 3 6 0 1 1 0 2 4 10 0 3 5 7 9 0 1 3 0 1 3 0 1 8 0 1 7 1 1 7 2 1 5 Answer: unknown 2 2 2 2 2 2 2 2 2 2 2 unknown unknown unknown unknown 2 1 2 2 This test looks incorrect as they can't reach any bar after 1 My step-by-step barbell moving (though improved to add into under and out under the barbell only "right" worms without checking every worm) gives TLE on 8th test. Is segment tree needed? I solved without it.I also used "improved step-by-step barbell moving",but my solution was quite far from TLE. I modeled groove as int array,but if you use sorting on worms array and then search there some coordinates then you can possibly get TLE. Edited by author 06.03.2009 05:20 I solved this problem without sorting. I found difference d[this_step]=count[this_step]-count[prev_step], and after that count_squash_worm=count_squash_worm+d[this_step]. Edited by author 09.03.2009 15:06 Just slide ahead and once you step on a worm by left or right plate, increase number of times that worm was stepped on (that number will drift between 0, 1, 2). When number of plates intersecting the worm changes between 0 and 1, total amount of affected worms changes accordingly. This algo can support overlapping worms and 1e+9 coordinates with sorting of worm endpoints. Hello, everyone. Just wanted to summarize some info about this problem. Ok, my code got AC with following things in it: 1. My pi was 3.1415926535897932384626433 (perhaps it is enough) 2. I used this formula from wikipedia deltaArc=acos(sin(phiA)*sin(phiB)+cos(phiA)*cos(phiB)*cos(deltaL)); distance = deltaArc*3437.5; (see the first formula from wikipedia http://en.wikipedia.org/wiki/Great-circle_distance)3. I used the following condition: if(100.00-distance>0.005) printf("DANGER!\n"); Hope it will help somebody. thanks a lot ...your formula is really useful.^_^ Used everynth what is written here. However still WA8. Any new ideas?... Do u know that pi can be calculated by this formula: atan(1) * 4? acos(-1) Also if you use acos on dot-product to get distance over sphere, beware that acos(-1.000000001) or acos(+1.000000001) will give NaN, so clamp argument to [-1, +1] range explicitly. Edited by author 07.03.2010 10:26 Hi, Alright guys I have solved the problem. Being a newbie to c# caused me to submit program 35 times. I didn't realize that Math.Round() function will change 100.00 to 100 instead. Here are the lines which I changed. double miles = distance(ship_latitude_radian, ship_longitude_radian, iceberg_latitude_radian, iceberg_longitude_radian); if (Math.Round(miles, 2) < 100.00) { Console.WriteLine("The distance to the iceberg: {0:F2} miles.", miles); Console.WriteLine("DANGER!"); } else { Console.WriteLine("The distance to the iceberg: {0:F2} miles.", miles); } Solved by making the following comparison in java: if (Math.round(distance*100) < 10000) { System.out.println("DANGER!"); } it will force it to compare with 2 digits precision. Edited by author 14.07.2026 14:28 diameter of 6875 miles (/ 2 = 3437.5)??? the mean radius of earth is 6371.0 km (3958.8 miles) Nautical miles are different You have to check all edges between centroids, not just arbitrary one. Although it leads to O(N^4) due to N^2 BFSes on cliques, early cutoff on max-dist from roots vs. current result makes it almost O(N^3). AC 0.046 sec You may output edge nodes in any order (1 2) or (2 1) checker accepts that We cannot imagine the test where our prog will give wrong answer! I wonder too, always wa on test 2 1w1 01w01a Edited by author 24.04.2007 19:29 No, its not 2nd test. My prog correctly process it, but stil WA2. sorted: 01w01 01w1 01w01a z000 z00 z00p z0p and one more 0 0p 01 1 1p Edited by author 25.04.2007 20:03 Yeap, that`s it... Thx. Try this test: z0p z00pp z0pp z00pp00 z000pp01 z00pp01 z0pp01 z001pp00 z01pp00 z1pp00000 z01pp01 z1pp001pp0 z1pp01pp000 I get WA#2 too. Huge thanks to Alexander Kouprin, after running his test and solving the problem I got accepted. Test from Alexander Georgiev also helped me a lot. By the way, my program gives other output for some test from this thread. Here they are: abc00125a abc0125a abc00125b abc0125b abc000000000000000000000125a abc00000000000000000000125a abc0012000000000000000000000000005b abc012000000000000000000000000005b These tests have almost broken my mind while I have been thinking why they are correct and I'm happy that I do not have to fix my program because of them. Zeroes matters only if strings are equal. Try this: abc0125a abc00125a abc00125b abc0125b Try this: abc0125a abc00125a abc00125b abc0125b I suppose the last test by Peter Huggy is the most similar to second test but after all this tests WA6 Try this: abc00000000000000000000125a abc000000000000000000000125a abc0012000000000000000000000000005b abc012000000000000000000000000005b I suppose the last test by Peter Huggy is the most similar to second test but after all this tests WA6 Got AC, thanks to Alias tests :) You can also try: 0000000 000 (Already sorted) Thank to everybody! =) Your program must return for these tests next results (alredy sorted): 1) 000 00 0 2) 00 0 000a 3) 00a000 00a0 I don't understand this. Why is 0000000 smaller than 000? What's the logic behind it? Edited by author 12.01.2021 22:30 I think logic behind it is when strings are equal on "japanese" interchanging alpha-numeric sequences, then the whole strings are compared, so that puts 001 before 01 and 002 before 02. Only 000 and 00 stand aside, so it's a matter of consistency with other numeric values. Or think of it the other way - append something like '~' (ASCII 126) to the end of the sting, that will put 001~ before 01~ and 000~ before 00~ I try to output zeros in this case, but seems like I'm wrong please show me some example for example for this case 2 11 11 Edited by author 11.12.2007 21:50 This test is correct, and the answer should be 00 00 The test is correct, original sequences do not need to be compatible Can someone give me a little hint, please ? make 2 sequences (s1 and s2) such that s1[i]+s2[i]<>2 My solution is based on a greedy approach. Thank you both ! :-) I think that an algorithm has many special cases. Main rool:to correct firstly s2[i] from 1 to 0 in pair s1[i]=1 and s2[i]=1 diminishing B but have pair 0, 0 in older position correcting it to 0, 1 for final increasing lexiographicly of B Who can find all cases he solve the problem After getting AC i have counted 6 cases next tests correspong each of cases 4 1011 0011 1011 0100 4 1010 0111 1011 0000 4 1011 0110 1100 0000 4 1111 0101 0000 0000 4 1010 0101 1011 0000 4 1011 0100 1100 0000 Edited by author 21.02.2007 13:58 My program successfully passed all of your test cases, but I still WA3... What can it be??? You are need in additional tests Best if you will create them yourself I have only 3 cases 1) attempt to build a >b 2) attempt to build a+1 0 3) build 0 0 A + B = A XOR B iff there is no carry, or in other words A AND B = 0 So the algo is simple Find leftmost x such that p[x]=q[x]=1. if none, assume x=n+1. Find rightmost y to the left of x such that p[y]=q[y]=0. If none, output p+1, 0 (p+1 may become 0). Otherwise set q[y]=1, and q[y+1..n]=0 Edited by author 12.07.2026 04:38 This task has some problems with accurancy, but 878 is too big rating for it. Agreed. On precision - performing multiplications before division and comparing at 1e-8 works. Can anybody expalain me this problem? I think that in both samples answer is YES, because all vertices are next to refuge or to museum. At last I've solved it. what about solution: 1) for maxflow use RelabelToFront 2) WA 36 : try this test 5 3 2 2 3 1 2 3 1 2 2 3 answer: NO 3) WA 38: test 5 3 2 2 2 1 2 3 1 2 2 3 answer: NO Try test 2 27 I got also WA at #6 and made some tests on the input. It seems that the line if (N == 34 && M == 49) while (1); got TLE (6) so the test is 34 49. My answer to this test is a-niaacgvtxwdouniwkovyjlpaaaerlqkyo niaacgvtxwdouniwkovyjlpaaaerlqkyp-aaarepihxnlfzhjsqrzpokzcbpyfypjwat aaarepihxnlfzhjsqrzpokzcbpyfypjwau-aqaaaaaaaaiiovpgvvmsnhsbbrtjgmuqbw aqaaaaaaaaiiovpgvvmsnhsbbrtjgmuqbx-bejdhnxluhaaainzrkuauccrqbastmtecb bejdhnxluhaaainzrkuauccrqbastmtecc-bssejrqozpnkflharcuholuvjdvwynyaaa bssejrqozpnkflharcuholuvjdvwynyaaa-chbflvjseyarrdiqpnyomjekfzqbtgnktz chbflvjseyarrdiqpnyomjekfzqbtgnkua-cvkgnzcvkgnzcvkgnzcvkgnzcvkgnzcvkm cvkgnzcvkgnzcvkgnzcvkgnzcvkgnzcvkn-djthqcvyppbgonlwmkhcidxnzrelirsgaz djthqcvyppbgonlwmkhcidxnzrelirsgba-dycisgpbuxooafnmkvljgbhcwmyqdkhqrm dycisgpbuxooafnmkvljgbhcwmyqdkhqrn-emljukifaapbxjvblttjroekmwfuxvlxyx emljukifaapbxjvblttjroekmwfuxvlxyy-faukwobifopcxpqshrtxbwaaaxbkkpmjnr faukwobifopcxpqshrtxbwaaaxbkkpmjns-fpdlyrulkxckjhsigcydztjvnaayrhdnnv fpdlyrulkxckjhsigcydztjvnaayrhdnnw-gdmnachtlazghlttujryytfbucbeeqsbil gdmnachtlazghlttujryytfbucbeeqsbim-grvoczgrvoczgrvoczgrvoczgrvoczgrvv grvoczgrvoczgrvoczgrvoczgrvoczgrvw-hgepfczvawqgsjxebkkytlmodnpsxrwcmh hgepfczvawqgsjxebkkytlmodnpsxrwcmi-hunqhgsygfdoebytzvpfriwdajjxsklnct hunqhgsygfdoebytzvpfriwdajjxsklncu-iiwrjkmblnqvpuajygtmpgfrxfecndaxtf iiwrjkmblnqvpuajygtmpgfrxfecndaxtg-ixfslofeqwedbmbzwrxtndpguayhhvqijr ixfslofeqwedbmbzwrxtndpguayhhvqijs-jlotnryhwerknedpvdcalayvqwsmcoftaa jlotnryhwerknedpvdcalayvqwsmcoftaa-jzxupvrlbnerywfftoghiyiknsmqxgvdqp jzxupvrlbnerywfftoghiyiknsmqxgvdqq-kogvrzkogvrzkogvrzkogvrzkogvrzkohb kogvrzkogvrzkogvrzkogvrzkogvrzkohc-lcpwuddrmefgwgilqkovetbohkbamrzyxn lcpwuddrmefgwgilqkovetbohkbamrzyxo-lqyxwgwurmsohykbovtccqldefvfhkpjnz lqyxwgwurmsohykbovtccqldefvfhkpjoa-mfhyykpxwvfvtqlrngxjanusbbpkcdeuel mfhyykpxwvfvtqlrngxjanusbbpkcdeuem-mtraaaaaaadyagcaylnbwefjfiwhlkxzyt mtraaaaaaadyagcaylnbwefjfiwhlkxzyu-niaaaaaamqmtnchcwhigpdmsazucrszvdb niaaaaaamqmtnchcwhigpdmsazucrszvdc-nwjcevvhmutscsqniokdufxkroxymgzaaa nwjcevvhmutscsqniokdufxkroxymgzaaa-oksdgzoksdgzoksdgzoksdgzoksdgzoksh oksdgzoksdgzoksdgzoksdgzoksdgzoksi-ozbejdhnxluhaabhlcxuvdfatyrziklvtv ozbejdhnxluhaabhlcxuvdfatyrziklvtw-pnkflharcuholuvjdvwynyaabjmfvzjyxn pnkflharcuholuvjdvwynyaabjmfvzjyxo-qbtgnktuicuvxmwzchbflvjseyarrdiqpr qbtgnktuicuvxmwzchbflvjseyarrdiqps-qqchpomxnlidjeypacedivahvrcqaaaaaa qqchpomxnlidjeypacedivahvrcqaaaaaa-relirsgastvkuxaezdjthqcvyppbgonlwp relirsgastvkuxaezdjthqcvyppbgonlwq-rsujtvzdycisgpbuxooafnmkvljgbhcwnb rsujtvzdycisgpbuxooafnmkvljgbhcwnc-shdkvzshdkvzshdkvzshdkvzshdkvzshdn shdkvzshdkvzshdkvzshdkvzshdkvzshdo-svmlydlkitjhdzfaukwobifopcxpqshrtz svmlydlkitjhdzfaukwobifopcxpqshrua-tjvnacjothflsugpqhyezmsbiabaabensx tjvnacjothflsugpqhyezmsbiabaabensy-tyeockxqtkjwbjigrhfbxcysiulzgdmnax tyeockxqtkjwbjigrhfbxcysiulzgdmnay-umnpeoqtysxdnbjwpsjivaihfqgeawbxrj umnpeoqtysxdnbjwpsjivaihfqgeawbxrk-vawqgsjxebkkytlmodnpsxrwcmaivorihv vawqgsjxebkkytlmodnpsxrwcmaivorihw-vpfriwdajjxsklncmorwqvbkzhunqhgsyh vpfriwdajjxsklncmorwqvbkzhunqhgsyi-wdoskzwdoskzwdoskzwdoskzwdoskzwdot wdoskzwdoskzwdoskzwdoskzwdoskzwdou-wrxtndpguayhhvqijlabeukemqvwvdoaaa wrxtndpguayhhvqijlabeukemqvwvdoaaa-xgguphijzjlotnryhwerknedpvdcaaaaud xgguphijzjlotnryhwerknedpvdcaaaaue-xupvrlbnerywfftoghiyiknsmqxgvdqjmd xupvrlbnerywfftoghiyiknsmqxgvdqjme-yiywtouqkamdqxveesnfghxhjmrlpwfucp yiywtouqkamdqxveesnfghxhjmrlpwfucq-yxhxvsntpizlcpwuddrmefgwgilqkovetb yxhxvsntpizlcpwuddrmefgwgilqkovetc-zlqyxwgwurmsohykbovtccqldefvfhkpjn zlqyxwgwurmsohykbovtccqldefvfhkpjo-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Can anyone write the correct answer? Thank you Edited by author 19.03.2008 18:53 I don't understant what's wrong, here are the number of pieces each processor has: 34 49 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683277 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 27285448088939550474430463423979178157730683276 (26^34) % M = 10 so I distributed the 10 remaining strings on the first processors, according to the sample test (when the remainder was 2) Any hint? solved! 'bssejrqozpnkflharcuholuvjdvwynyaaa' on processor 5 and 6 is obviously wrong input: 34 49 output: a-niabcscehmgkraoxkdfwwinvutdtrojpm niabcscehmgkraoxkdfwwinvutdtrojpn-abrbdglfjpznwjcevvhmutscsqniokdufz abrbdglfjpznwjcevvhmutscsqniokduga-aqacfkeioymvibduugltsrbrpmhnjctewm aqacfkeioymvibduugltsrbrpmhnjctewn-bejdhnxluhacttfksrqaqolgmibsdvipmz bejdhnxluhacttfksrqaqolgmibsdvipna-bssejrqozpnkflharcuholuvjdvwynyadm bssejrqozpnkflharcuholuvjdvwynyadn-chbflvjseyarrdiqpnyomjekfzqbtgnktz chbflvjseyarrdiqpnyomjekfzqbtgnkua-cvkgnzcvkgnzcvkgnzcvkgnzcvkgnzcvkm cvkgnzcvkgnzcvkgnzcvkgnzcvkgnzcvkn-djthqcvyppbgonlwmkhcidxnzrelirsgaz djthqcvyppbgonlwmkhcidxnzrelirsgba-dycisgpbuxooafnmkvljgbhcwmyqdkhqrm dycisgpbuxooafnmkvljgbhcwmyqdkhqrn-emljukifagbvlxpcjgpqdyqrtisuycxbhz emljukifagbvlxpcjgpqdyqrtisuycxbia-faukwobifopcxpqshrtxbwagqemzsvmlyl faukwobifopcxpqshrtxbwagqemzsvmlym-fpdlyrulkxckjhsigcydztjvnahenobwox fpdlyrulkxckjhsigcydztjvnahenobwoy-gdmnavnoqfpruztyeockxqtkjwbjigrhfj gdmnavnoqfpruztyeockxqtkjwbjigrhfk-grvoczgrvoczgrvoczgrvoczgrvoczgrvv grvoczgrvoczgrvoczgrvoczgrvoczgrvw-hgepfczvawqgsjxebkkytlmodnpsxrwcmh hgepfczvawqgsjxebkkytlmodnpsxrwcmi-hunqhgsygfdoebytzvpfriwdajjxsklnct hunqhgsygfdoebytzvpfriwdajjxsklncu-iiwrjkmblnqvpuajygtmpgfrxfecndaxtf iiwrjkmblnqvpuajygtmpgfrxfecndaxtg-ixfslofeqwedbmbzwrxtndpguayhhvqijr ixfslofeqwedbmbzwrxtndpguayhhvqijs-jlotnryhwerknedpvdcalayvqwsmcoftad jlotnryhwerknedpvdcalayvqwsmcoftae-jzxupvrlbnerywfftoghiyiknsmqxgvdqp jzxupvrlbnerywfftoghiyiknsmqxgvdqq-kogvrzkogvrzkogvrzkogvrzkogvrzkohb kogvrzkogvrzkogvrzkogvrzkogvrzkohc-lcpwuddrmefgwgilqkovetbohkbamrzyxn lcpwuddrmefgwgilqkovetbohkbamrzyxo-lqyxwgwurmsohykbovtccqldefvfhkpjnz lqyxwgwurmsohykbovtccqldefvfhkpjoa-mfhyykpxwvfvtqlrngxjanusbbpkcdeuel mfhyykpxwvfvtqlrngxjanusbbpkcdeuem-mtraaojbcdtdfinhlsbpylegxxjowvueux mtraaojbcdtdfinhlsbpylegxxjowvueuy-niabcscehmgkraoxkdfwwinvutdtrojplj niabcscehmgkraoxkdfwwinvutdtrojplk-nwjcevvhmutscsqniokdufxkroxymgzabv nwjcevvhmutscsqniokdufxkroxymgzabw-oksdgzoksdgzoksdgzoksdgzoksdgzoksh oksdgzoksdgzoksdgzoksdgzoksdgzoksi-ozbejdhnxluhacttfksrqaqolgmibsdvit ozbejdhnxluhacttfksrqaqolgmibsdviu-pnkflharcuholuvjdvwynyadicgmwktfzf pnkflharcuholuvjdvwynyadicgmwktfzg-qbtgnktuicuvxmwzchbflvjseyarrdiqpr qbtgnktuicuvxmwzchbflvjseyarrdiqps-qqchpomxnlidjeypasfmjsthbtuwlvybgd qqchpomxnlidjeypasfmjsthbtuwlvybge-relirsgastvkuxaezdjthqcvyppbgonlwp relirsgastvkuxaezdjthqcvyppbgonlwq-rsujtvzdycisgpbuxooafnmkvljgbhcwnb rsujtvzdycisgpbuxooafnmkvljgbhcwnc-shdkvzshdkvzshdkvzshdkvzshdkvzshdn shdkvzshdkvzshdkvzshdkvzshdkvzshdo-svmlydlkitjhdzfaukwobifopcxpqshrtz svmlydlkitjhdzfaukwobifopcxpqshrua-tjvnahenobwoprgqswauzfpdlyrulkxckl tjvnahenobwoprgqswauzfpdlyrulkxckm-tyeockxqtkjwbjigrhfbxcysiulzgdmnax tyeockxqtkjwbjigrhfbxcysiulzgdmnay-umnpeoqtysxdnbjwpsjivaihfqgeawbxrj umnpeoqtysxdnbjwpsjivaihfqgeawbxrk-vawqgsjxebkkytlmodnpsxrwcmaivorihv vawqgsjxebkkytlmodnpsxrwcmaivorihw-vpfriwdajjxsklncmorwqvbkzhunqhgsyh vpfriwdajjxsklncmorwqvbkzhunqhgsyi-wdoskzwdoskzwdoskzwdoskzwdoskzwdot wdoskzwdoskzwdoskzwdoskzwdoskzwdou-wrxtndpguayhhvqijlakmpuoszixfsloff wrxtndpguayhhvqijlakmpuoszixfslofg-xgguphijzjlotnryhwerknedpvdcalayvr xgguphijzjlotnryhwerknedpvdcalayvs-xupvrlbnerywfftoghiyiknsmqxgvdqjmd xupvrlbnerywfftoghiyiknsmqxgvdqjme-yiywtouqkamdqxveesnfghxhjmrlpwfucp yiywtouqkamdqxveesnfghxhjmrlpwfucq-yxhxvsntpizlcpwuddrmefgwgilqkovetb yxhxvsntpizlcpwuddrmefgwgilqkovetc-zlqyxwgwurmsohykbovtccqldefvfhkpjn zlqyxwgwurmsohykbovtccqldefvfhkpjo-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Thanks for the test :) I solved it using base-26 long arithmetics, but forgot to prepend leading zeroes (leading 'a'), so could output "brg" instead of "aabrg" Calculate powers of 26 and prefix sums of powers of 26. Calculate ranges by integer division. Calculate each password from left to right like you would calculate k-permutation using factorial digit system. Base-26 arithmetics simplifies things a lot here :) It's not clear if black player can continue movement or not after eating white bishop. Bishop moves first, so if at first pawn can capture bishop it does not matter. On the next moves bishop can avoid such positions where pawn can capture it. Just according to problem statement it's white wins :), so looks weird Please, check 142 test, C++ fread failed for this test case. scanf accepted. After fread I can try trim space symbols (ASCII code <= 32) from start and end, any more WA142. Any hint for solving this problem? number of possible operations is only 1m > number of possible operations is only 1m Hah! Somehow reading this here (even though it's clear in the problem statement) made me see the way...thanks. memcpy (for c++) and million.., and not any more ;p |
|