Common Boardusing System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks;   namespace ConsoleApp9 {     class Program     {         static void Main(string[] args)         {             int a1;             a1 = Convert.ToInt32(Console.ReadLine());             if (a1 >= 1 && a1 <= 2000)             if (a1 >= 1 && a1 <= 4)             {                 Console.WriteLine("few");             }             if (a1 >= 5 && a1 <= 9)             {                 Console.WriteLine("several");             }             if (a1 >= 10 && a1 <= 19)             {                 Console.WriteLine("pack");             }             if (a1 >= 20 && a1 <= 49)             {                 Console.WriteLine("lots");             }             if (a1 >= 50 && a1 <= 99)             {                 Console.WriteLine("horde");             }             if (a1 >= 100 && a1 <= 249)             {                 Console.WriteLine("thorg");             }             if (a1 >= 250 && a1 <= 499)             {                 Console.WriteLine("swarm");             }             if (a1 >= 500 && a1 <= 999)             {                 Console.WriteLine("zounds");             }             if (a1 >= 1000)             {                 Console.WriteLine("legion");             }             return;         }       } } Is it the same problem if I placed containers in linear massive?   Edited by author 17.07.2006 18:02 Give me some tests Please! I had WA #21 too. But there was no something special, just stupid mistake. I stored the input not in Matrix, but in Array. And I filled it wrong; My wrong way:  (in pascal) for i := 1 to n do   for j := 1 to m do     read(Mat[(i-1)*n + j]); My correct way: for i := 1 to n do   for j := 1 to m do     read(Mat[(i-1)*m + j]); May be it will help you. And here is test which helped me find my mistake: 2 3 6 1 1 1 1 1 1 Answer: 2. Thank you very much, i did same mistake :D My algorithm passes all the tests I have designed, but still misses test 1. Can I get the input for this test ? I have the same problem: I picked up all test data in this discussion and my program seems to be perfectly answering on all this test. Here test data and my answers:   Test1 (from task description):   5 7 1 4 1 1 3 300 3 1 10 1 2 16 2 3 100 2 5 15 5 3 20 4 3 1 2 10 1 3 20 1 4 30 -1   Answer is 2 1 3 5 No solution.   Well, it is not exactly the same, but seems to be correct   Test #2 5 6 1 5 1 3 5 100 3 4 2 2 4 1 4 5 10 1 2 1 -1   And the answer is 2 3 4   Test #3 6 7 1 2 1 2 3 1 3 2 1 2 1 1 4 5 2 5 6 2 6 4 2 -1   Answer is 4 6 5   Test #4 2 2 1 2 10 1 2 20 -1   Answer is No solution.   Test #5 6 9 1 2 1 2 3 100 3 4 1 4 5 100 5 6 1 6 1 100 1 4 5 2 5 5 3 6 5 -1   Answer is 3 4 1 2 5 6   Test #6 5 0 6 1 1 2 3 -1   Answer is No solution. No solution.   Test #7 4 4 1 2 10 2 3 1 3 4 1 4 1 1 -1   Answer is 1 4 3 2   And test #8 5 6 1 5 1 3 5 100 3 4 2 2 4 1 4 5 10 1 2 1 -1   Answer is 1 5 4 2     But I am still getting WA#1 Could you suggest more data or any advise? Solved the problem, it was IO issue Hi   I seem to have issue with solution for the test cases you have provided. May be I'm wrong and missing something. Please help. For this test case below 5 7 1 4 1 1 3 300 3 1 10 1 2 16 2 3 100 2 5 15 5 3 20   You state the solution as 2 1 3 5. But from the input, there is no edge from 2 to 1 or 3 to 5  (or 5 to 2 required to make this a round trip). Am I reading your answers wrong? I see this issue with each of your test case. Many of the the edges in solution are not there in the input.   Please explain.   ~bonfire.     Edited by author 22.03.2018 02:33 Test #2 answer should be 2 4 5 1 I would suggest you to think about sumulating all possible situations like dropping eggs from first floor, from second, from third ,..., from n-th and we must choose then worst case scenario, but try to minimize that result.
 
 
  It worked. Optimization is really out of this world) n=int(input()) print(math.ceil(n/(9*5))) i=0 while(n>9):     print(9,end='')     n-=9     i+=1     if i%5==0:         print(end=' ') print(n) the elements must be different. You repeat them test 3 ??? help me please Runtime error? Wrong A ! test 3 please can anyone tell me what is the test of 3. register user1 1 success: new user added register user2 2 success: new user added register user3 3 success: new user added logout user2 fail: already logged out login user1 3 fail: incorrect password login user2 2 success: user logged in logout user3 fail: already logged out   note the last line Try this:   4 register a 1 register a 2 register a 3 register a 4 And that the last line is not so? Like everything correctly. It is easy. Just if else and use map, and define a new data structure, and there you go, all done. you may have problem with double login:   register v 1 success: new user added login v 1 success: user logged in login v 1 fail: already logged in 2 register x y register x y     Out success: new user added fail: user already exists Try this!   input: 3 register a 1 login a 1 login a 2   output: success: new user added success: user logged in fail: incorrect password     NOTE! Login with wrong pw should output "fail: incorrect password" instead of "fail: already logged in". Great. I didn't notice that. I thought that using the sieve of Eratosthenes would slow down the program, but it turned out the opposite. What is the output for this test?   996 997 754 543 100 42 25 119 17 70 96 293 581 96 391 57 102 888 313 458 55 238 385 15 195 3 576 216 47 117 41 75 849 407 769 87 25 884 319 620 66 94 886 27 552 86 561 377 149 206 90 413 209 74 198 78 32 914 11 840 7 76 814 288 447 72 42 892 370 579 82 42 813 165 677 26 123 561 104 424 38 14 521 154 368 2 120 63 4 38 88 43 887 76 772 71 113 750 88 384 24 78 255 87 138 17 59 862 263 760 44 272 386 117 255 33 368 453 223 330 77 148 846 214 480 76 191 671 219 487 46 305 685 332 436 15 197 356 15 254 37 203 406 74 362 84 14 916 157 603 68 102 287 57 167 98 340 560 81 331 40 7 986 251 728 91 116 791 251 412 92 53 486 13 330 61 8 268 107 217 65 467 304 49 304 22 25 924 250 471 63 430 73 12 38 25 456 462 110 318 80 435 389 102 288 34 673 84 13 59 18 714 7 0 5 32 208 602 7 571 97 189 307 50 232 28 10 836 280 491 56 601 119 42 78 95 36 312 28 229 8 63 821 273 479 35 117 279 126 168 89 195 787 162 421 45 658 59 26 39 74 857 106 18 58 94 269 677 48 445 10 79 636 134 572 31 65 842 214 673 62 294 395 51 308 100 239 197 51 133 20 758 209 10 194 39 26 900 437 721 51 56 712 197 536 6 256 553 93 334 9 210 662 57 598 58 558 371 185 309 47 294 535 222 439 81 265 728 100 713 13 107 464 212 349 27 8 987 137 644 67 43 480 78 355 79 197 644 185 596 99 567 64 10 36 21 62 781 254 502 23 968 5 0 4 69 69 849 92 599 36 66 585 92 382 49 8 747 110 618 73 329 79 9 69 16 366 217 14 161 70 468 527 245 283 93 149 547 252 498 48 35 883 9 797 52 138 611 108 401 60 286 430 104 222 53 119 188 90 152 1 199 505 24 502 5 149 603 73 477 43 325 577 224 399 75 179 709 254 483 29 42 597 212 537 54 585 140 45 105 19 9 680 97 664 11 58 886 281 847 12 223 96 42 93 4 578 228 10 211 14 27 563 94 368 83 67 895 178 778 30 51 882 225 579 50 304 637 315 332 59 99 850 127 762 64 346 19 1 19 85 270 502 185 306 I haven't got AC but  this is my answer for this test : 16 3005 16 3005 is right! :-)   I've AC :-) Good test :) With all that weird positioning I forgot about L>=XT for basement shell :P Why are there two boards in line 7 abbb answer: abbba abbbb answer: abbbba   Edited by author 25.11.2020 01:48   Edited by author 25.11.2020 01:50 Can someone help how to make C# code faster? Here is my code:   using System; using System.Collections.Generic; class Program     {         static int countCut(List<int>[] nods, List<int> uncheckedNodes)         {             int next = 0;             int count = 0;             do             {                 count++;                 watchCut(nods, uncheckedNodes, next);                 if (uncheckedNodes.Count > 0)                     next = uncheckedNodes[0];                 else                     next = -1;             } while (next != -1);             return count;         }         static void watchCut(List<int>[] nods, List<int> uncheckedNodes, int node)         {             uncheckedNodes.Remove(node);             for (int i = 0; i < nods[node].Count; i++)             {                 if (uncheckedNodes.Contains(nods[node][i]))                     watchCut(nods, uncheckedNodes, nods[node][i]);             }         }         static void Main(string[] args)         {             string[] inp_NM = Console.ReadLine().Split(' ');             int N, M;             N = Convert.ToInt32(inp_NM[0]);             M = Convert.ToInt32(inp_NM[1]);             int[,] threads = new int[M, 2];             List<int>[] nods = new List<int>[N];             for (int i = 0; i < N; i++) nods[i] = new List<int>();             for (int i = 0; i < M; i++)             {                 string[] inp_thread = Console.ReadLine().Split(' ');                 threads[i, 0] = Convert.ToInt32(inp_thread[0]) - 1;                 threads[i, 1] = Convert.ToInt32(inp_thread[1]) - 1;                     nods[threads[i, 0]].Add(threads[i, 1]);                     nods[threads[i, 1]].Add(threads[i, 0]);             }             int Q;             Q = Convert.ToInt32(Console.ReadLine());             int[] cuts = new int[Q];             string[] inp_tear = Console.ReadLine().Split(' ');             for (int i = 0; i < Q; i++)             {                 cuts[i] = Convert.ToInt32(inp_tear[i]) - 1;             }             for (int i = 0; i < Q; i++)             {                     nods[threads[cuts[i], 0]].Remove(threads[cuts[i], 1]);                     nods[threads[cuts[i], 1]].Remove(threads[cuts[i], 0]);                 List<int> uncheckedNodes = new List<int>();                 for (int l = 0; l < N; l++) uncheckedNodes.Add(l);                 Console.Write(countCut(nods, uncheckedNodes)+" ");             }           }     }   Edited by author 24.11.2020 08:00 In this problem you should use disjoint-set(система непересекающихся множеств). I had MLE on test 33. I just changed int to short and 1,0 to bool Sorry if this is too obvious   Edited by author 22.11.2020 16:48 #include <iostream> #include <string> #include <vector> #include <set>   const std::string &solution(const std::vector<std::string> &penguins);   int main() {     int n;     std::cin >> n;     std::cin.clear();     std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');     std::vector<std::string> penguins;     penguins.reserve(n);     for (int i = 0; i < n; ++i) {         std::string penguin;         std::getline(std::cin, penguin);         penguins.emplace_back(std::move(penguin));     }     std::cout << solution(penguins) << std::endl;     return 0; }   const std::string &solution(const std::vector<std::string> &penguins) {     std::set<std::string> penguinSet(penguins.begin(), penguins.end());     auto setIterator = penguinSet.begin();     std::set<std::string>::iterator mostNumerous;     int maxCount = 0;     while (setIterator != penguinSet.end()) {         int count = 0;         for (const auto &penguin : penguins) {             if (*setIterator == penguin) {                 count++;             }         }         if (count > maxCount) {             maxCount = count;             mostNumerous = setIterator;         }         setIterator++;     }     return *mostNumerous; }   I tested locally and it works... Problem 1394 "Ships. Version 2" is the same problem as 1115 but has full testset. Problem 1115 has only first 10 tests.   All latest submissions on 1115 were moved to new problem. You can resubmit you solutions to 1115 also if you want.   Problem 1115 was rejudged with 10 tests. But some submissions got WA. So change the text 1115, because two problems now have the same limits for N, M and interval length. Or just delete the problem 1115. If you can write a solution that works within 5-10 seconds for any test I make, I wolud increase TL. Wouldn't you like to share with us? I use two algorithms inside one program: First I try to arrange ships using heuristics with randomization. If it fails for many times (say, 1000 times) I use bruteforce with optimizations (just like many people)   I found a big numbers of different bruteforces and heuristics for this problem. I have tests for all that methods. You need just one good combination! My program works well on all tests, I've already checked more than 30 billions random tests.   A little hint: my bruteforce gets TLE 22, heuristics gets TLE 17. Good luck! the idea is great! I have thought for too many strange ideas like netflow.....but not this one!   i gonna try to solve it right now. Where is your good solution at now? The present-day test is too tough for your algorithm? If this the edge, it may be worth keeping the time limit so that one top solution has always been AC. It will be reasonable to increase the TL to 3s. It is required to inspect all the current solutions thoroughly to decide whether all of them have some "tweaking" for specific tests or not. If any of them is universal (i.e. actually not depends on any seed or magic number), then time limit can be even capped on that. If not, then it is reasonable to increase TL somehow. I can bet that some of accepted solutions will not pass for some permutation of actual tests and that is not ok when them will require to be adjusted in order to pass!   Edited by author 21.11.2020 11:53 I sort input before use. What do you mean?   Edited by author 16.12.2020 00:35 Don't use double or you will suck hard. My formulas are definitely correct (because I got AC), but with double and framework functions like Math.Sqrt I was getting very big inaccuracies (about FEW degrees for angles between tangent and shots). Then I switched to BigInteger and got AC immediately.   Edited by author 19.11.2020 04:59 #include <iostream> using namespace std; int main() {     long long i, j, iDel; long long biggestV = 9999999, biggestDel = 9999999;     cin >> i >> j;     if (i == 1) {         cout << 1;         return 0;     }     else if (i == j) {         cout << i;         return 0;     }     else if (i + 1 == j) {         cout << (j % 2 != 0 ? j : i);         return 0;     }     for (long long iV = j % 2 != 0 ? j : j-1; iV >= i; iV -= 2) {         for (iDel = j / 3 + 1; iDel >= 1; iDel--) {             if (iV%iDel == 0) {                 if (iDel < biggestDel) {                     biggestDel = iDel;                     biggestV = iV;                 }                 break;             }         }         if (iDel == 1) {             cout << iV;             return 0;         }     }     cout << biggestV; } In the main cycle you doesn't compare trivialities, you search the smallest biggest divisor in the weird range instead. Could you please show the mathematical proof of your main cycle?   Edited by author 31.03.2020 14:11   Edited by author 31.03.2020 14:12 Hi.Did you solve this problem? ---- ll l,r;     cin >> l >> r;     if(l==1){         cout << 1;         return 0;     }     if(l == r){         cout << l;         return 0;     }     ll n = 1e6+2;     vector<bool> prime(n+1,1);     prime[0]=prime[1] = 0;     for( ll i =2; i*i <= n; i++)     {         if(prime[i])         {             for(ll j = i*i; j <= n; j+=i)                 prime[j]=0;         }     }       for(ll i = r; i >= l; i--){         if(prime[i])         {               cout << i;             return 0;         }     }     double mx =1e11;     ll ans = 0;     for(ll i = r; i >= l; i--){           if(i % 2 == 0)             continue;             double suma = 1;         for(ll k = 2; k*k <= i; k++){               if( i % k == 0 ){                 suma += k;                 if(i/k != k){                       suma += (i/k);                 }             }         }           double q=(suma)/(i);             if( q < mx){             mx = q;             ans = i;         }       }     cout << ans;     return 0; ----   I used the sieve of Eratosthenes to find prime numbers. If I have not found prime numbers on the interval [l; r], then I iterate over all numbers with [l; r]. I go through the divisors (sqrt (i)). I calculate the minimum. What's wrong? WA 11. Google translator, sorry. if you wanna get 20 lines solutions, write me on dalydudan@gmail.com  |  
  |