Common Boardthis is simple test for TEST 25. 10 -1 0 1 2 0 0 -1 -1 -1 2 Answer : 2 1 2 Edited by author 07.11.2013 16:13 That's not a valid test since you can't begin with -1, popping an empty stack. Give me, please, first 10-15 answers. It's not hard to get the correct formula for this problem, but harder to implement it because of high precision required. At last I had to use precalculated array for getting AC. Here's your answers: 2 -> 1.5 3 -> 2.25 4 -> 3.21428571 5 -> 4.48571429 6 -> 6.21981567 7 -> 8.64673579 8 -> 12.1044438 9 -> 17.0919353 10 -> 24.3495978 What was the issue? For me straightforward implementation in C++ using double got AC easily. How did you take 100th power of 3/2? I can't think it out. I've never used decimal long arithmetic. Edited by author 03.01.2013 16:06 Edited by author 03.01.2013 16:06 It is useful to remember that standard double type can store numbers up to 10^300 (and even a bit more). (3/2)^100 < 2^100 < 10^35 => no problem to compute it in double. And since you need relative accuracy of only 7 digits => 16+ digits that double variable stores is more than enough to compute what you need. Actually, here with usual double you can calculate answers for n up to 500+. Is it really true? I always thought that double type takes only 8 bytes of memory and hence cannot store such big numbers. But anyway thank you. Maybe I just have bad compiler or bad implementation as always :) good test: n=40 ans=3688328.070956036 The problem asks for at least 6 correct decimals. I had to compute up to 100 decimals (in intermediate computations) to get the required precision in the final answer for n = 100. Here is the (censored) answer for the biggest possible test: n = 100 answer = 13552*3*4*4*1*6*18.186159417 Are you kidding? My dumb solution in python ACCed in 0.3 sec:D Edited by author 24.05.2014 01:07 What is test #25? me help test --------------------------------------------------- 16 cipher grille kamkohob names grillee pcodes newtests rejudge timus size volume summit watchmen braineater twosides solution random yesorno keywords subversion commands bosses shooting shaitan game strategy playgame mnemonic palindromes bestname eligibility rectangle rules txxxxxxx txxxyzasd txxxxxas volvo vlot volt vvv vvilia vvobla what is it zina whashing potatoes 2 1 7 10 9 6 11 3 8 4 5 12 13 14 15 16 ------------------------------------------------ answer is ------------------------------------------------ grillee kamkohob keywords mnemonic playgame random rectangle rejudge shaitan size twosides txxxxxas vlot vvilia what zina For your test,i got the same answer ,but my code wa#20 I've had this problem too. THen i found my mistake. My function that compared two strings and returned the lower one: f f("aa","aaaa")="aa"; f("aaaaa","aa")="aaaaa"; - this was a mistake. It should have returned "aa" sorry for my English Why? This is my solution: #include <iostream> using namespace std; int main(){ long int a,b,f=0; long int k=1; cin>>a>>b; if (a==1) { f=0; cout<<f; return 0;
}
if (b>=a && a<=2) f=1;
else if(a!=1){ while (k<=b){ f++; k*=2;
} a -=k; while (a>0){ f++; a=a-b;
} } cout<<f;
return 0; } Some test for your program 10 1 ans 9 3 8 ans 2 Some test for your program 10 1 ans 9 3 8 ans 2 Спасибо, помогло=) I got WA #7 several times. If u also got WA just try this test: 9 5 O-O-O-O-O |\ \|/ /| O-O O O-O |/|\ /|\| O-O-O-O-O It helped me to get AC. why this is accepted but in the acmp wrong answer 2 461 in acmp Edited by author 15.01.2014 14:54 Because there numbers may be even. Restrictions on number K are different #include <cmath> #include <iomanip> #include <iostream> using namespace std; int main () { double number [100000]; int i=0; while ( ! cin.eof()) { cin >> number [i]; i++; } for( int j=i-1; j>=0; j--) { cout<< setprecision (4) << sqrt(number[j])<<endl; } return 0; } here's my program but I don't know what's wrong.. when i put the number of elements of the array to 140000 it says "stack overflow", when i put 10000 it says wrong answer. All local variables are allocated in stack. Array "number"[] is local, because it is described in function "main". Standard size of stack is 1 MB, size of double variable is 8 bytes. So it isn't enough space to allocate all array with 140000 elements. You should increase stack size. http://acm.timus.ru/help.aspx?topic=cpp #pragma comment(linker, "/STACK:16777216") Edited by author 22.05.2014 15:07This my results. For this task, time limit is 1.0 second, so why it happend with 0.265 time? 5520909 12:24:55 21 фев 2014 svg2003 1915. Руины титанов: воссоздание былого Visual C# 2010 Time limit exceeded 42 0.265 49 708 КБ Edited by author 21.02.2014 12:30 Edited by author 21.02.2014 12:31 May be 0.265 is time of last succefull test. Looks like test 42 uses geometric progression - coins double many times. So solution should work with unlimited stacks. I solve this problem with dp. Cool problem, similar to the Levenshtein,but with some differents. if you have WA 43 and 51, check this tests 0 00 000 0000 00000 1 01 001 0001 00001 answers is primitive - 1,1,1,1,1,2,2,2,2,2 Module Module1 Sub Main() Dim a() As String = Console.ReadLine.Split(" ") Dim n, k As Integer n = 2 * CInt(a(0)) k = CInt(a(1)) Dim rez As Integer = Math.Ceiling(n / k) Console.WriteLine(rez) End Sub End Module Test data: 10 11 Answer: 2 I got wrong answer for test#8 but my output is 2. What is wrong? Edited by author 12.05.2014 00:54 what's wrong in my code, please give me some test #include <iostream> #include <vector> #include <string> #include <map> using namespace std; map<string,string>functions; map<string,string>variables; int main(){ int count_function, count_variable,i,j; string line,s1,s2,s, type; cin >> count_function; for(i = 0; i < count_function; i ++){ cin >> s1; while(cin >> s){ if(s == ":") break; s1 = s1 + " " + s; } cin >> s2; functions[s1] = s2; }
cin >> count_variable;
vector<string>variable; vector<string>types;
for(i = 0; i < count_variable; i ++){ cin >> type >> s >> s1 >> s1; while(s1[s1.size() - 1] != ')'){ cin >> s2; s1 = s1 + " " + s2; } if(variables.find(s) == variables.end()){ s2 = ""; j = 0; while(s1[j] != '(') s2 += s1[j++]; s2 += '('; j ++; while(s1[j] != ')'){ line = ""; while(s1[j] != ',' && s1[j] != ')') line += s1[j++]; if(variables.find(line) == variables.end()){ cout << "Error on line " << i + 1 << ": " << "Unknown variable" << endl; return 0; } s2 += variables[line]; if(s1[j] == ','){ s2 += ", "; j += 2; } } s2 += ')';
if(functions.find(s2) == functions.end()){ cout << "Error on line " << i + 1 << ": " << "No such function" << endl; return 0; }
s2 = functions[s2];
if(type == "auto"){ variable.push_back(s); types.push_back(s2); type = s2; } if(type != s2){ cout << "Error on line " << i + 1 << ": " << "Invalid initialization" << endl; return 0; } variables[s] = s2; }else{ cout << "Error on line 2: Double declaration" << endl; return 0; } } for(i = 0; i < types.size(); i ++) cout << variable[i] << " : " << types[i] << endl; return 0; } If you have WA#8 then check that m >= h Thanks a lot. if m<h then writeln('NO'). WA 10. Give this test please... Have trouble with this test too... and one question: if input is like that: 7 6 1 2 3 4 5 6 7 should be output like that: 1 3 4 5 6 7 2 or that: 1 3 5 7 2 4 6 The answer is: 1 3 5 7 2 4 6 Remember about the correct number of spaces. My AC program show : 1 3 4 5 6 7 2 it is incorrect answer or test >the columns have the same height with the possible exception of the last column, which may be shorter This test is incorrect. Timus Online Judje Team likes give people incorrect tests. The second word should be "crowd", according to the Russian translation. var a:array[1..1000] of string; S, pol:string; N, i, j, dlina:longint; function Sum(i, j:integer):string; var k:string; var i1:integer; begin k:=''; for i1:= i to j do k:=k+a[i1]; Sum:=k; end; function Sum1(i, j:integer):string; var k:string; var i1:integer; begin k:=''; for i1:= j downto i do k:=k+a[i1]; Sum1:=k; end; begin readln(S); N:=length(S); for i:= 1 to N do a[i]:=copy(lowercase(S), i, 1); dlina:=0; for i:= 1 to N-1 do begin for j:= i+1 to N do if (Sum(i, j)=Sum1(i, j)) and (length(sum(i, j))>dlina) then begin pol:=Sum(i, j); dlina:= length(sum(i, j)); end; end; writeln(pol); end. I always get WA in #5 here is my code, somebody help me please. <code> #include<stack> #include<iostream> #include<algorithm> #include<vector> #include<list> #include<iterator> using namespace std; int getSafe(vector<string> a,int an, vector<string> b, int bn){ int d=0; for(int i=0;i<an;i++){ for(int j=0;j<bn;j++) if(a[i]==b[j]){ d++; break; } } return d; } struct ve{ vector<string> v; }; int main(){ int n,N,m; cin>>N; string str; vector<string> menu; for(int i=0;i<N;i++){ cin>>str; menu.push_back(str); } cin>>n; int a,b; cin>>b; vector<string> fMenu; for(int i=0;i<b;i++){ cin>>str; fMenu.push_back(str); } int i=0; int nums[102]; ve res[102]; while(i<n){ cin>>a; nums[i]=a; for(int j=0;j<a;j++){ //cout<<"d"; cin>>str; //cout<<"s"; res[i].v.push_back(str); } i++; } cin>>m; for(int i=0;i<n;i++){ int x=getSafe(res[i].v,nums[i],fMenu,n); int c=getSafe(menu,N,res[i].v,nums[i]); if(x-nums[i]==0) cout<<"YES\n"; else if(N-b-nums[i]+x-m<0) cout<<"NO\n"; else cout<<"MAYBE\n"; } return 0; } </code> |
|