Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Rename this task to "Stucks" | maslowmw | 1220. Stacks | 18 сен 2019 20:02 | 1 |
just a joke Edited by author 18.09.2019 20:08 |
Is there a solution for n>22292? | Felix_Mate | 2047. Математика | 17 сен 2019 09:11 | 5 |
My full search say that solution exist for n<=22292 There is solution for all n <= 10^5 though I still can not fast enough generate answer I've solved this problem using DP. Hint: The maximum sum of numbers for required sequence does not exceed 1568617. According to my calculations the largest such sequence can be 344001 for the constraints of the problem. answer for every n exists there is no possibility to output “impossible” |
help | Vorobeva | 1110. Степень | 17 сен 2019 02:10 | 1 |
help Vorobeva 17 сен 2019 02:10 class Program { public static void Mod(int N, int M, int Y) { int f = 0, t = -1; for (int i = 0; i < M; i++) { int X = i; long y = X; for (int j = 2; j < N + 1; j++) { y = y * X; y = y % M; } if (y == Y) { if (f > 0) Console.Write($" "); Console.Write($"{X}"); f++; } } if (f == 0) Console.Write($"{t}"); Console.WriteLine(); } } Edited by author 17.09.2019 02:10 |
WA 4 | Beqa Lomitashvili [Freeuni] | 1476. Лунокод | 16 сен 2019 22:02 | 2 |
WA 4 Beqa Lomitashvili [Freeuni] 10 апр 2014 00:07 I've got WA on 4th test. Can anyone tell me some tests to check my solution? You have to use BigInteger, you can't simply use Long Long bc the answer can go up to 2^(1600) |
Upcoming site maintenance announcement | Alexander Klepinin (USU) | | 16 сен 2019 15:55 | 1 |
Just for information. On September 19 this site will be under maintenance, so it will be unavailable for about 5 hours starting from 10:00 GMT+5. Sorry for inconvenience. Edited by author 16.09.2019 15:55 |
O(n) | 0blivium | 1296. Гиперпереход | 16 сен 2019 02:37 | 2 |
O(n) 0blivium 4 янв 2019 02:58 Note, the required algorithm is known as the Kadane's algorithm and runs in O(n). |
why the solution is what it looks like | fatnet | 1984. Охранник компота | 15 сен 2019 17:20 | 2 |
ive googled that the answer for all n except 1 is 1 + 1/sin(PI/n), can smb explane me why? Centers of circles form a regular polygon with side length 2. Now, consider the formula to find circumradius of a regular polygon and add 1 because you were connecting circle centres, but not their tangent points to the circle. |
What is 6th test | Valentin_Borisov | 1740. А олени лучше! | 14 сен 2019 12:50 | 6 |
Give some tests or hints to understand logic of calculating Edited by author 01.11.2009 14:30 Try test 31 10 2 This test helped me to receive AC... Is the answer "6.00000 8.00000"? |
Wrong Answer on Test #16 | Shabab Karim | 1280. Topological Sorting | 14 сен 2019 01:26 | 4 |
What is Test #16? Please someone help! What is Test #16? Please someone help! Same here... got stuck in Test-16 . so why did you get the WA16? Well maybe someone gonna read this but i got WA #16 cause my logic was wrong. i thought that i need to check if i studied any of prerequisite BUT i must check if i studied ALL OF them. maybe my code would help idk #include <iostream> #include <vector> using namespace std; int N, M, a[(int)1e3 + 5], b, c; bool visited[(int)1e3 + 5], flag, ans = true; vector <vector <int> > adj((int)1e3 + 5); int main() { cin >> N >> M; while(M--) cin >> b >> c, adj[c].push_back(b); for(int i = 0; i < N;++i) { cin >> a[i]; flag = true; visited[a[i]] = true; if(adj[a[i]].empty()) continue; for(int j = 0; j < adj[a[i]].size();++j) if(!visited[adj[a[i]][j]]) flag = false; if(!flag) ans = false; } if(!ans) cout <<"NO"; else cout << "YES"; } |
shortest solution | LSBG | 1231. Тьюринг: раз, два, три, … | 13 сен 2019 18:47 | 5 |
I have the feeling that this problem can not be solved with less then 9*k+7 rows in the control table(my solution has exactly 9*k+7 rows) but I have not proven it. Has anybody a shorter solution? Edited by author 06.04.2008 23:24 It can be solved using O(log(n) + log(k)) rows. Do it like that: 1) put AA right before # to the left. This is 00 written base 26. 2) go right until you encounter -. Put + there and then go left until you hit #. Increase that number (it will become AB). Then go right again. 3) if you encounter # while walking right, go left and compute coordinate of last - mathematically using cells to the left as memory with base-26 2-digit arithmetics. For arbitrary k and n it will be more than 2 of course, that's why it's O(log(k)+log(n)), but not a constant. 4) like in case of 2 run right/left by putting - instead of + until result becomes zero (decrease it with every - set). 5) Find rightmost - and paint everything to the left with + 6) Find - and stop there Though, I heard in this forum that the checker is wrong as it stops when there are n-1 pluses, but not when invalid state/character pair is met. So, actually you will have to use O(n) states to calculate 'n' and then bring back this value to calculation area inside read/write head :) My solution for each k output 604 lines. How did you do this? My solution uses 1003 lines for each k, and I don't know how to optimize it :( I also came up with 604 lines solution. Just go to the right incrementing the state (200 instructions), then output "X # something_related_to_josephus # <" for X in range [2, 201]. You've spent 400 states. Now your state number should have the information how many steps left you should make outputting '+' -- you will need 199 instructions for this. After that you'll have to add 5 more instructions JOSEPHUS_POINT - LEFT_MODE - < LEFT_MODE - LEFT_MODE + < LEFT_MODE # RIGHT_MODE # > RIGHT_MODE + RIGHT_MODE + > RIGHT_MODE - FINISH - = |
Can't understand the problem | Skeef79 | 1855. Между светом и тьмой | 12 сен 2019 13:51 | 3 |
How is it possible?? Establish 2 4 = 2.6667? 1 2 3 4 1 2 2 (2+2)/2 = 2 I don't understand what you mean there. In fact, the problem asks for an interval [l, r] to find the average cost of a sub-interval. That is, as for the first test case. After two 'change' queries we have cost(1, 2) = 1; cost(2, 3) = 2, cost(3, 4) = 2. Then we are asked for the average on the interval [2, 4] which is (cost(2, 3) + cost(3, 4) + cost(2, 4)) / 3. So, given an interval [l, r] you are asked to compute: int64_t n_of_intervals = 0; int64_t total_sum = 0; for (int i = l; i < r; ++i) for (int j = i + 1; j <= r; ++j) n_of_intervals += 1 total_sum += cost(i, j) output total_sum / n_of_intervals |
Hint | 198808xc | 1832. Шоу «Ариран» | 11 сен 2019 11:49 | 7 |
Hint 198808xc 5 сен 2011 12:33 I have got AC with bruteforce. You need only to state larger memory for stack (if you use stack), and perform some little optimization when enumerating. PS: Solution always exists. For n <= 300000, the task could be finished with only 14 (or 15?) colors. BTW: If anyone could provide me a method of construction, I would be very glad to see it. Please paste it here, and let others see. What do you mean under "the method of construction"? For example I solved it using greedy algo. And, as I know, it's very hard to prove that for some fixed n solution doesn't exist. Therefore jury checked a possibility of coloring artists for all n <= MAXN with a help of their own method (maybe, also greedy). According to this time limit and MAXN for this problem were selected. What I said under "the method of construction" means that you have such a method, that you could use some formula or equation to calculate elements at each place DIRECTLY. More precisely, you have a formula for a[n]: a[0] = ... a[1] = ... ... a[n - 1] = ... That is "the method of construction". Many problems in TIMUS could be solved with this kind of method, and I wonder whether this problem could be done too. Hmm, it's very interesting. But I don't know such method. And I guess, such solution doesn't exist for every natural N. Edited by author 08.09.2011 22:00 Edited by author 09.09.2011 11:11 Look at author rating for this problem. There are 0.031 and even 0.015 solutions. I don't think they did bruteforce too. Edited by author 24.11.2011 00:33 Эта задача имеет математическое решение. Нам задан граф на N вершинах, причём степень каждой вершины p (нужно самому понять, откуда берётся p). Требуется покрасить вершины так, чтобы смежные имели разный цвет. Утверждение: покраска возможна <=> цветов >=p+1. Необходимость очевидна. А достаточность реализуется по индукции: пусть мы покрасили k<N вершин, так что смежные имеют разный цвет. Возьмём не покрашенную вершину. Её степень <=p, а цветов >=p+1.Тогда покрасим её в любой из оставшихся цветов. There is a constructive approach that works in O(n). Hint: LCM(1, 2, ..., 13) > 3*10^5. |
No subject | sashabusse | 1046. Геометрические грёзы | 10 сен 2019 19:33 | 1 |
Edited by author 10.09.2019 21:16 |
How to get <0.02 sec.? | Andrej Bourgasov | 1510. Порядок | 10 сен 2019 14:44 | 3 |
Hey guys, how to get run time under 0.02s? I implement O(n) solution, but my time is ~0.15s for CLang... What optimisations do you use? I used fast I/O to get 0.031. There are faster input methods that use fwrite/fread while mine is based on getChar/writeChar. Perhaps using even faster I/O can get you to 0.015 [code deleted] Edited by author 10.09.2019 14:33 Edited by moderator 24.11.2019 13:26 And yes. I got accepted in 0.015s using fread/fwrite IO and C language compiler (not C++) |
I've tried everything but still MLE | achvanov | 1306. Медиана последовательности | 9 сен 2019 22:16 | 2 |
I've tried priority_queue and heap, but still MLE. Here's my code, can somebody help me? #include <iostream> #include <algorithm> #include <vector> int main() { int n, a; std::cin >> n; std::vector<int> v(n / 2 + 1); for (int i = 0; i < n / 2 + 1; ++i) { std::cin >> v[i]; } std::make_heap(v.begin(), v.end()); for (int i = 0; i < (n + 1) / 2 - 1; ++i) { std::cin >> a; v.push_back(a); std::push_heap(v.begin(), v.end()); std::pop_heap(v.begin(), v.end()); v.pop_back(); } std::sort_heap(v.begin(), v.end()); if (n % 2) { std::cout << v.back() << ".0"; } else { a = v.back(); v.pop_back(); std::cout << (0ll + a + v.back()) / 2 << '.'; if ((0ll + a + v.back()) % 2) { std::cout << 5; } else { std::cout << 0; } }
return 0; } It's wrong. Because the last leaf of the max heap is not necessarily minimum but you are removing it (v.pop_back();). Your code may remove the median element. And the sort_heap has no effect. |
Hint | Skeef79 | 1645. Лыжная гонка | 9 сен 2019 21:59 | 1 |
Hint Skeef79 9 сен 2019 21:59 Count numbers bigger than a[i] from 0..i-1 ans smaller than a[i] from i+1..n-1 ans then try to build the answer :) |
Difficulty | Skeef79 | 1645. Лыжная гонка | 9 сен 2019 21:58 | 1 |
It is around 70 Edited by author 09.09.2019 22:01 |
C: murder. Help please | Georg | 1001. Обратный корень | 8 сен 2019 11:20 | 2 |
[code deleted] Edited by author 08.09.2019 10:26 Edited by moderator 19.11.2019 23:32 Решил с грехом пополам, здесь писать не буду. Остались сомнения, что в условии(в тестах) правильно размер массива подсчитан, этот(SIZE) не катит. |
What to do? | bsu.mmf.team | 1890. Деньги из воздуха | 7 сен 2019 22:32 | 2 |
OMG, standart interval tree gives TLE 6. It's terrible! Why?! Use Segment Trees with lazy propagation |
AC | qwertyqwe | 1124. Мозаика | 7 сен 2019 13:54 | 1 |
AC qwertyqwe 7 сен 2019 13:54 Please, could you send your problem(AC code) |