|
|
Общий форумwhat is the answer for the following test bbbb wwwb wbwb wbbb my AC code shows that answer is 7, is that right? My AC program show answer 5 coordinates: 1:1, 1:2, 2:2, 2:3, 1:4, board becomes all black Edited by author 07.06.2011 00:10 yes that's what i'm talking about, my code fails on that test, but i got AC. i think it need to add test That to admins ;) What algo you're used? Your different submissions takes significand different time. Looks like random-based algo ) Edited by author 07.06.2011 00:26 i used recursion, those ones which execution time was higher had just deeper recursion My non-Accepted program gives 5. I have WA#11 needn't all 2^16 search, divide it two part each 8 bit. Can you please share some tests? Answer was correct on every test from forum, still can't pass test 14 + implemented all the hints, including rounding with 0.5000000001 and searching near the optimal values :( Thanks in advance! Edited by author 28.12.2016 02:12 my program calculate: Input: ====================================== String str = "10.23\n" + "0\n" + ".04\n" + "1\n" + "-0.051e0\n" + "1\n" + "1.1e30\n" + "10\n" + "-1.1E-30\n" + "1\n" + "2468097632.1358642324268913e-2\n" + "20\n" + "e23\n" + "3\n" + "1 e3\n" + "1\n" + "-7293874219874982174982174987321e-18446744073709551616\n" + "10\n" + "#1234\n" + "3\n" + " 12.0\n" + "3\n" + "2E-1\n" + "3\n" + "-\n" + "2\n" + ".e1\n" + "2\n" + "#"; ====================================== Output: ====================================== 10 0.0 0.0 1100000000000000000000000000000.0000000000 0.0 24680976.32135864232426891300 Not a floating point number Not a floating point number 0.0000000000 Not a floating point number Not a floating point number 0.200 Not a floating point number Not a floating point number ====================================== It's correct. why wrong test-12? try also -7293874219874982174982174987321E-18446744073709551616 10 -7293874219874982174982174987321E-4294967296 10 -7293874219874982174982174987321E-65536 10 -7293874219874982174982174987321E-256 10 9126492316491641269352615215701236589213658621356281376589216562319562396592381659862195621281E-190 100 1234E-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 2 # (note that last two - is long strings. That only displayed in this forum as several lines Edited by author 27.05.2011 21:51 Input: ============================= String str = "-7293874219874982174982174987321E-18446744073709551616\n" + "10\n" + "-7293874219874982174982174987321E-4294967296\n" + "10\n" + "-7293874219874982174982174987321E-65536\n" + "10\n" + "-7293874219874982174982174987321E-256\n" + "10\n" + "9126492316491641269352615215701236589213658621356281376589216562319562396592381659862195621281E-190\n" + "100\n" + "1234E-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\n" + "2\n" + "#"; ================================== Output: ================================== 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009126 12.34 ================================== It's correct. Edited by author 30.05.2011 14:22 There are some more examples? try 9E-9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 100 -1E-1 5 send to me your solution at aterlux @ mail . ru if you want, I'll take a look Edited by author 30.05.2011 17:20 Input: ============================= String str = "9E-9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n" + "100\n" + "-1E-1\n" + "5\n" + "#"; ================================== Output: ================================== 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0.10000 ================================== It's correct. I have resolved! It's my bug. My program has not processed this case: ====== +.0 0 ====== This example has this answer: ====== 0 ====== But my program has this answer: ====== Not a floating point number ====== I passed all the above cases including the +.0 0 but still WA. I had WA#3 because of how I was reading the input in C: while (gets(buff) != NULL) { int i = 0; while (buff[i] != '\0') { // process char by char i++; } } Changed to: while ((c = getchar()) != EOF) { // process char by char } And it works AC!!! Hello! Can somebody tell me if there is a faster algo than O(Q^2*N)? My algo works pretty fast, but I wondered if there is a better way to do it. My solution Q*N, lol Or no I'm not sure Edited by author 11.03.2016 21:50 Edited by author 11.03.2016 21:50 My algo is fills dp[vertex][presaved edges] array (result is dp[1][Q]), where total loops N^3/6 < 2*10^5. There maximum presaved edges = Q, but more vertexes have less edges than Q. Let edges[v] - number of edges of v vertex. So there O( N * sum( edges[ v ] * ( edges[ v ] + 1 ) / 2 ) ) = O( N^3 / 6 ). you must write "not eoln" no "not eof" and you'll got AC!! THANK YOU!!! Very much! Had WA1. Got desperate, rly, can't find any mistakes. Can't believe it was it. Change this tiny word and get AC! Still, why it makes such difference? #include <iostream> #include <vector> #include <string> int corrections = 0; bool words_match(const std::string& w1, const std::string& w2); void process_word(const std::vector<std::string>& dict, const std::string& word); int main(){ std::vector<std::string> dictionary; std::string curr_dict_word; std::getline(std::cin, curr_dict_word); while(curr_dict_word != "#"){ dictionary.push_back(curr_dict_word); std::getline(std::cin, curr_dict_word); } char c; std::string cword; while(std::cin.read(&c,1)){ if('a'<=c && 'z'>=c){ cword.insert(cword.end(), c); continue; } else if(!cword.empty()){ process_word(dictionary, cword); cword = ""; } std::cout << c; } if(!cword.empty()){ process_word(dictionary, cword); } std::cout << corrections << std::endl; return 0; } bool words_match(const std::string& w1, const std::string& w2){ if(w1.length() != w2.length()){ return false; } bool mismatch = false; for(int i = 0; i < w1.length(); ++i){ if(w1[i] != w2[i]){ if(mismatch){ return false; } mismatch = true; } } return mismatch; } void process_word(const std::vector<std::string>& dict, const std::string& word){ for(int i = 0; i < dict.size(); ++i){ if(words_match(dict[i], word)){ std::cout << dict[i]; ++corrections; return; } } std::cout << word; } Please don't post your solution here. Maybe there is just small limits or not right topic?? My solution is O(n^2*logn) and works ~1.7 seconds. But some people got AC in .078. How? I solved it with next algo: I bruteforce all possible connections (if graph consists of several not connected parts) and then add some edges for Euler path with greedy. Of course its right algo, but some complicated (i think). Does anyone knows more simple one? Only use buffered i/o )). Подскажите кто нибудь что я делаю неправильно? import java.util.*; import static java.lang.Math.*; public class Sqrt{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.println(sqrt(in.nextInt())); } } The main method I followed was to first compare two of the arrays and extract the similar values in another array. I then compared that array with the third array, and updated the counter each time there was a match in eigenvalues. This method avoids comparing all the arrays together, and hence takes up less time. So in essence number of operations reduces to O(2*N^2) instead of O(N^3). However, more sophisticated algorithms like binary search are more effective. But still I include this method for people like myself, who are new to algorithms. Hope it helps someone. Thank you! Did as you said and get Accepted)) 0.046 seconds (FreePascal) Any hints for this problem? Try solve 2 sub problems when dodecahedron on odd position and not. var j,i,n:longint; m:array of real; begin n:=1; while not seekeof do begin read(j); SetLength(m,n); m[n]:=sqrt(j); inc(n); end; for i:=n to 1 do writeln(m[i]:0:4); end. 1. chek type of j. You may have input = 10^18, but max in longint ≈ 2*10^9. 2. Write size of array. 2. Don't know what this is: SetLength(m,n); delete this nah) 3. for i:=n to 1 do |=> for i:=n downto 1 do 4. Chek why for this input: 9. your output is 0.0000 3.0000 little change your programm and get AC)) Edited by author 18.12.2016 03:29 I don't understand what's wrong in my program. Give me test 9 please is there something invalid in test cases?? Help! What is in the test 26? |
|
|