Common BoardI do not understand why, but my program gives different result, than sample. in this picture, i draw a figure with yellow, i think area of this figure is an answer, i am right ? download this picture: http://slil.ru/28091271Question is simple. H is not diven then we have plane problem. Two adjacent, rejion after antey+ antey itself. You filled with yellow only the area behind the new building. But the big inner circle must be included in "non-seen" region as well. I think, that this problem can be solved only via integrals. Analytic geometry doesn't work. I am right? No!i tried to use integral during contest: WA8- rounding error. At the next day I found simple analytic solution. Are you sure, that it is simple solution? =) A think, that main problem is that we can't make any Circle Sector, except sector from the center of town, so we can't find exact area behind New Antey Building. Areas of figures with rounded border are hardly calculated. The figure can be decomposed into triangles and circle segments. All lengths and , therefore areas are easy calculated, typical school problem. Edited by author 18.10.2009 17:15 Solution on Java exists! No problems with accuracy of calculating. the link for the diagram has expired can anyone draw a figure and upload again, the area to find out is unclear to refer to from the question. The new tower blocks its own area plus all the town behind it. This sum needs to be divided by (pi * R**2) and multiplied by 100. Does anyone know the input for test 7? If you use fmod(...,360), remember that for negative input you get negative output. The time limit for the problem has been corrected from 2.0 sec to 1.0 sec. The new value better reflects the original expectations for accepted solutions back from 2006. Around 40 authors have lost their AC (mostly submitted since 2017). just print the max sum of three consecutive numbers and also the index of the middle element of the numbers. If there is a way to improve, let me know: #ifdef __MINGW32__ #define uputchar _putchar_nolock #define ugetchar _getchar_nolock #define ufread _fread_nolock #define funlock _unlock_file #else #define uputchar putchar_unlocked #define ugetchar getchar_unlocked #define ufread fread_unlocked #define funlock funlockfile #endif namespace { #if 1 struct { int c; int operator * () const { return c; } auto & operator ++ () { c = ugetchar(); return *this; } auto operator ++ (int) { auto prev = *this; operator ++ (); return prev; } } cursor; #else char input[(1 << 21) + (1 << 19)]; auto cursor = input; auto input_size = cursor - input; #endif inline void skip_ws() { for (;;) { switch (*++cursor) { case ' ' : case '\t' : case '\r' : case '\n' : break; default : return; } } } inline void read_input() { //std::cin.tie(nullptr); std::ios::sync_with_stdio(false); #if 0 #ifdef ONLINE_JUDGE cursor += ufread(input, sizeof(char), sizeof input, stdin); #else { const char s[] = R"(4 0 0 1 0 0 1 1 2 2 0 0 0 2)"; cursor = std::copy(s, s + sizeof s - 1, cursor); } #endif //assert(cursor < input + sizeof input); //assert(input + 0 != nullptr); input_size = cursor - input; cursor = input - 1; #endif } template< typename U > void read_uint(U & u) { static_assert(std::is_unsigned< U >::value, "!"); u = 0; for (;;) { char c = *cursor; if ((c < '0') || ('9' < c)) { break; } ++cursor; u = (u * 10) + (c - '0'); } } template< typename I > void read_int(I & i) { char sign = *cursor; switch (sign) { case '+' : case '-' : ++cursor; } std::make_unsigned_t< I > u = 0; for (;;) { char c = *cursor; if ((c < '0') || ('9' < c)) { break; } ++cursor; u = (u * 10) + (c - '0'); } i = I(u); if (sign == '-') { i = -i; } } template< typename F > void read_float(F & result) { static_assert(std::is_floating_point< F >::value, "!"); char c = *cursor; std::uint8_t significand[std::numeric_limits< F >::digits10]; auto s = significand; std::int32_t after = 0; std::int32_t before = 0; char sign = c; switch (c) { case '-' : case '+' : c = *++cursor; } [&] { bool d = false; for (;;) { switch (c) { case '.' : before = 1; break; case '0' ... '9' : { if (c != '0') { d = true; } if (0 < before) { ++before; } if (d) { *s++ = (c - '0'); if (s == significand + sizeof significand) { std::int32_t a = 0; for (;;) { switch ((c = *++cursor)) { case '0' ... '9' : ++a; break; case '.' : after = a; break; default : if ((before == 0) && (after == 0)) { after = a; } return; } } } } break; } default : if (!d) { *s++ = 0; } return; } c = *++cursor; } }(); if (0 < before) { after -= (before - 1); } std::uint32_t exponent = 0; switch (c) { case 'e' : case 'E' : { c = *++cursor; char esign = c; switch (c) { case '-' : case '+' : c = *++cursor; break; } [&] { for (;;) { switch (c) { case '0' ... '9' : exponent = (exponent * 10) + (c - '0'); break; default : { return; } } c = *++cursor; } }(); if (esign == '-') { after -= exponent; } else { after += exponent; } } } alignas(32) std::uint8_t bcd[10] = {}; std::uint32_t b = 0; do { --s; if ((b % 2) == 0) { bcd[b / 2] = *s; } else { bcd[b / 2] |= (*s << 4); } ++b; } while (s != significand); if (sign == '-') { bcd[9] = (1 << 7); } asm( "fldl2t;" "fildl %[exp10];" "fmulp;" "fld %%st;" "frndint;" "fxch;" "fsub %%st(1), %%st;" "f2xm1;" "fld1;" "faddp;" "fscale;" "fstp %%st(1);" "fbld %[tbyte];" "fmulp;" : "=t"(result) : [exp10]"m"(after), [tbyte]"m"(bcd) : "st(1)", "st(2)" ); } template< typename I > void print_int(I value) { if (value == 0) { uputchar('0'); return; } std::make_unsigned_t< I > v; if (value < 0) { uputchar('-'); v = decltype(v)(-value); } else { v = decltype(v)(value); } I rev = v; I count = 0; while ((rev % 10) == 0) { ++count; rev /= 10; } rev = 0; while (v != 0) { rev = (rev * 10) + (v % 10); v /= 10; } while (rev != 0) { uputchar("0123456789"[rev % 10]); rev /= 10; } while (0 != count) { --count; uputchar('0'); } } } import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(in.nextInt()+in.nextInt()); } } Много весит и долго делает, подскажите, как облегчить и ускорить? you have to declare variables and place the input there. Файлы на java не могут много весить и запускаются всегда долго 1. I spent nearly a half of hour to clear that "a dangerous stuff" does not mean "student may be poisoned", but "he will be poisoned exactly because of the stuff". Why not use "a harmful stuff" everywhere? 2. And these words: "The food is cooked from M different food stuffs. There are N different food stuffs in the menu but not all of them are at the distribution...". Why not write "The distribution contains M different food stuffs from the menu. The menu consists of N different stuffs."? 3. So, I've understood that the distribution does not contains the stuffs from the first block. But it took much time because of bad description. Agree... simple problem, awful problem statement. if your program is /tmp/a.out and the input is /tmp/in, you can use the following Python 3 script to plot your output: from matplotlib.pyplot import * import subprocess f = open('/tmp/in') n = int(f.readline()) p = [[int(i) for i in l.split()] for l in f] print(p) out = subprocess.run('/tmp/a.out < /tmp/in', stdout=subprocess.PIPE, shell=True).stdout.decode().strip() res = [int(s) for s in out.split('\n')[1:]] print(res) plot([v[0] for v in p],[v[1] for v in p],'ro') plot([p[i-1][0] for i in res], [p[i-1][1] for i in res],'b-') axis('equal'); grid(); show() If you already have solved (simpler!) "1285. Thread in a Hyperspace", just replace N=8 with N=3. Can surface of the water be curved? no, but a sensor shows zero if the plane crosses the side below zero can you give some tests? for example: 10 10 0 0 0 0 0 0 0 0 0 0 in this test wright answer is "No chance.", but not "Dirty debug :(" 10 30 1 0 0 0 0 0 0 0 0 0 True answer No chance. (При равенстве штрафного времени команды сортируются по алфавиту, а значит, команда ZZZ в этом случае всё равно оказалась бы на втором месте. ) It is test 4. Also, Test 5 is related with the decision of 4 test. EPS=1e-8 precision for =0 comparisons is ok. Output 10 digits after decimal point is ok (6 digits gave WA41). The point to find is called Fermat point, check at mathworld.wolfram.com Yea, Fermat point.... or simple ternary search :) Outputting 6 decimal points works just fine. There is no need for epsilon tweaking: it can be solved with fractions (Python 3) except one Decimal (getcontext().prec=10) needed for sqrt(3). var n,i,o,c,p,x:integer; s:real; begin s:=0;p:=0; readln(n); for i:=1 to n do begin readln(o); s:=s+o; end; s:=s/n; if o = 3 then begin inc(c); writeln('None'); end; if s=5 then if (c<>1) then begin inc(p); writeln('Named');end; if s>=4.5 then if (c<>1)and (p<>1) then begin inc(x); writeln('High'); end; if (c<>1) and (p<>1) and (x<>1) then writeln('Common'); end. Edited by author 05.04.2018 22:47 where is my mistake? #include <cstdio> #include <cmath> inline int lb(int n) { return ceil(log(double(n))/log(2.0)); } int main() { int n,k; scanf("%d%d",&n,&k); if (n<=k) printf("%d",lb(n)); else { int ans=lb(k); n-=1l << ans; ans+=n/k; if (n%k) ++ans; printf("%d",ans); } } I got WA6 too...can you please tell me the case? Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. Could you explain, why it is better ? For WA #17 IN: 6 8 13 80 17 58 92 67 57 88 96 28 65 22 OUT: 6 ..... TLE #10 IN: 30 1 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 ...... 0 30 Edited by author 12.06.2011 15:01 The simplest search takes 0.4s, to finish in 0.015s cut the search once it is obvious that it cannot succeed, e.g., for each city index C calculate the set of cities that must be already covered once you decided what cities before C will be targeted. In the above TLE#10 example, if you continue search starting from 3, then 1 must be already covered, that is 1 or 2 must be targeted. BTW, bitset<N> is slightly slower than equivalent bit manipulations with int32_t, probably, because bitset uses uint64_t. using namespace std; #include<iostream> #include<string> #include<sstream> #include<ctype.h> void factorial(unsigned long n,unsigned long k); int main() { unsigned long counter=0; string s; unsigned long n; while(getline(cin,s)) { counter=0; string::size_type position,position2; position=s.find(' '); string num; for(int i=0;i<position;i++) { if(isdigit(s[i])) num+=s[i]; } stringstream ss(num); ss>>n; position2=s.find('!'); if(position2==position+1) { for(int i=position+1;i<s.size();i++) if(s[i]=='!') counter++; factorial(n,counter); } } } void factorial(unsigned long n,unsigned long k) { unsigned long res=1; int mod=n%k; unsigned long mul=n; if(mod!=0) { while(mul>1) { res*=mul; mul=mul-k; } cout<<res<<endl; } else { while(mul>=k) { res*=mul; mul=mul-k; } cout<<res<<endl; } } Edited by author 05.04.2018 15:46 Edited by author 05.04.2018 15:47 Why if there is no answer, we should print "5"? It must be included in problem description!!! Not 5, but we should add 30 minutes to difference we seek for. For instance, we've found "2H=9", what is unbelievable, 'cause it contradict the statement. But I increment this to get the even number 10=2*5. Answer: 5 hours. I still don't know why is it true. Update. I've just found my mistake. The tests are OK (but method of "increment" also works). Edited by author 07.08.2011 16:57 I not used any equations. I bruteforced through all possible differences, and if answer was not found then I was printing "5" (by advices from forum). Problem description is correct. Try this test: 01.01 21.59 04.23 09.22 Answer:4 But I think your solution will print 5 because of this condition. So people who got AC for this problem using this condition solved it incorrectly. Edited by author 23.10.2013 01:14 Edited by author 23.10.2013 01:14 I also tried bruteforce and on test 2 my program finds that there is no valid answer. However, if I just return 5 in case of failure program gets acc. I'd really like to know what test 2 is. By the way, my program outputs the correct answer on the test above. Try this test: 01.01 21.59 04.23 09.22 Answer:4 Should I care of patterns with incomplete square braces? For example 'a[b' (and probably treat '[' as a regular character for matching. Or there is no such tests? No such tests. (I like to put asserts in unclear cases like these and see if they fire) No [] or [^] either |
|