| Show all threads Hide all threads Show all messages Hide all messages |
| Hint for WA6 | Leonid (SLenik) Andrievskiy | 1612. Tram Forum | 14 Jun 2021 10:15 | 6 |
Try this tests INPUT tram OUTPUT Tram driver INPUT tram.tram trolleybus OUTPUT Tram driver Edited by author 10.03.2010 23:01 Test 6 is <tram,> or <trolleybus,>. (whitout <>) ;-) Edited by author 28.02.2014 17:38 |
| WA 25 | jiyujie | 1612. Tram Forum | 14 Jun 2021 10:14 | 3 |
WA 25 jiyujie 12 Apr 2012 21:34 i need some test... i guess the mistake is about "tram", i don't know which pattern of "tram*" should be counted I had a WA25 when didn't count last word. I assume there are empty lines there |
| The best solution! Only 0.015 sec and 78 Kb! | FANTOM | 1017. Staircases | 10 Jun 2021 13:10 | 10 |
My solution is fast! valery@uni.lg.ua Ha! My solution: only 0.001 sec and 70 Kb! And it's normal solution (no cheating). I sent it some minutes ago. PS: It's very good that your solution works fast but Always there is better one :) Ha-Ha! My solution works sometimes too 0.001, but how many iterations of your cycle on N=500? Ha-ha-ha! My solution is O(n^2) but I know O(sqrt(n)*n) one. sorry to bother u on such an old post...but can u help me on a better approach to this question Jokes on you! My solution is O(-∞) So, your solution travels back in time or make the time in the Universe acting backwards?:) |
| What is happening? | Savchuk Nickolay | 1001. Reverse Root | 10 Jun 2021 03:54 | 4 |
Why is here the runtime error on the 6 test? What test is 6? #include <iostream> #include <cmath> using namespace std; void ghjkl(long double p) {cout << fixed; cout.precision(4); cout << p << endl;} int main() { long double a[1000]={-1.0}; long long i=0; while(cin) {cin >> a[i]; i++;} i=i-2; long double b[1000]; for(int k=0; k<1000; k++) {b[k]=sqrt(a[k]);} for(int m=i; m>=0; m--) {ghjkl(b[m]);} return 0; } Edited by author 24.03.2021 16:53 Edited by author 24.03.2021 16:54 i don't know Edited by author 31.03.2021 19:27 Edited by author 31.03.2021 19:27 Edited by author 31.03.2021 19:27 Oh, I have understood. The array isn't the needed collection for this task. Stack is better. #include <iostream> #include <stack> #include <cmath> using namespace std; int main() { stack<double> a; double b; int c=0; while(cin) {cin >> b; a.push(b); c++;} c-=1; a.pop(); for(int i=0; i<c; i++) {cout << fixed; cout.precision(4); cout << sqrt(a.top()) << endl; a.pop();} return 0; } Edited by author 10.06.2021 03:35 Or you can use deque: #include <iostream> #include <queue> #include <cmath> using namespace std; int main() { deque<double> a; double b; int c=0; while(cin) {cin >> b; a.push_back(b); c++;} c-=1; a.pop_back(); for(int i=0; i<c; i++) {cout << fixed; cout.precision(4); cout << sqrt(a.back()) << endl; a.pop_back();} return 0; } |
| HINT | Varun Sharma | 1313. Some Words about Sport | 7 Jun 2021 10:23 | 3 |
HINT Varun Sharma 6 May 2009 10:26 Hi, Well it took me a while to figure out as to how to approach this problem but as it turned out it is pretty straightforward. I divided the problem into two parts. First I printed out the elements up until the middle diagonal. And then the elements after that. Here is the format of the numbers for 4 X 4 array 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 2,0 2,1 2,2 2,3 3,0 3,1 3,2 3,3 We can see a pattern here. First print the element 0,0. Then -> 1,0 to 0,1 (i = 1 to i = 0 and j = 0 to j = 1) Then -> 2,0 to 0,2 (i = 2 to i = 0 and j = 0 to j = 2) Then -> 3,0 to 0,3 (i = 3 to i = 0 and j = 0 to j = 3) So, basically as we are heading towards the main diagonal, we are increasing the value of i and at the same time running j from 0 to i. Implementing this will get you the first 10 out of 16. For the rest of them, we have the same pattern again but this time its reverse Then -> 3,1 to 1,3 (i = 3 to i = 1 and j = 1 to j = 3) Then -> 3,2 to 2,3 (i = 3 to i = 2 and j = 2 to j = 3) Then the last element 3,3 So, this just requires some clever manipulation of the for loops or while loops. Re: HINT Lifeisbeautiful 23 Dec 2020 12:53 |
| Logrithm | yyll | 1971. Graphics Settings | 4 Jun 2021 10:18 | 1 |
|
| be careful | Adhambek | 1143. Electric Path | 3 Jun 2021 20:26 | 2 |
In order to achieve absolute safety providing electricity to the camps, besides an electric supplying system, the host organization set up a path from a reserved electricity generator (which is placed in one of the camps) to every camp once, this means that, thare is only and only one path from Pi camp to Pj camp. The answer should be a path (successive line segments) NOT a tree (minimal spanning tree) NOT a Steiner tree (minimal spanning tree with additional points) |
| Эта задача на графы или на что-то другое? | Roman | 1744. The Captain's Squad | 2 Jun 2021 13:22 | 1 |
Можете дать подсказку? Я понял что количество всех пар всегда три И число дней как посчитать Но не могу подобрать алгоритм чтобы вывести в каком порядке будут солдаты выходить на дежурство Edited by author 02.06.2021 13:24 |
| Hint, Solution & Code(C++) | Asif Anwar Sajid | 1021. Sacrament of the Sum | 1 Jun 2021 13:46 | 2 |
Hint: Binary search!! Solution: This is a pretty easy binary search problem. All we need is to check for every number of the second list(as first list is sorted in ascending order) let's denote as x, if we can find y = 10000-x in the first list. If we find y for any x(from the 2nd list) then we will print "YES". Because we already got a pair x, y for which x + y = 10000. So, the complexity is NlogN(as we are doing binary search for every element of a list in the worst case). [Code was deleted] Edited by moderator 06.06.2021 03:06 Binary search is not needed here. It is enough to traverse the array with two pointers. |
| wa on test 2 | tawsifsazid | 1197. Lonesome Knight | 31 May 2021 15:14 | 3 |
WA on test 2 don't know why :( Edited by author 01.07.2016 14:09 Edited by author 01.07.2016 14:09 Edited by author 01.07.2016 14:09 Edited by author 01.07.2016 14:10 i keep having the same problem and i don't know why.Did you find out? It's 2021 now, so... have you found out the problem? :) |
| What on 4 Test?? C++ | Maksim`~ | 1100. Final Standings | 30 May 2021 12:55 | 1 |
|
| Hints? | Zergatul | 2124. Algebra on Segment | 29 May 2021 18:42 | 3 |
Hints? Zergatul 28 May 2021 19:19 We want to use segment tree, but we need to know how express some segment in order to preserve validity of multiplication and order calculation. I noticed any segment can be expressed by just 2 integers. I cannot proof this, my math background is not good here. Multiplication is trivial. Now we need ability to merge 2 segments (expressed by 1-2 integers) and get 2 another integers. I spent tens of hours thinking on this, but cannot come up with correct merge algorithm. Tried this: merge(x1, x2, x3, x4): if exists such i,j,k: where x[i]*x[j]%p=x[k], then we can remove x[k] if we preserve order else try to set x[i] = x[i]*x[j]%p for some random i,j repeat My merge procedure is not correct. Am I heading in the right direction?
I don't remember the problem quite well, but I think the main data structures you need in this problem are those that query for sum of segment and gcd on segment; maybe lcm. There are several approaches, some of which use discrete logarithm while others don't. In any case you would need some optimizations. I'm not sure what you are trying to do, so sorry if my comment is misleading and is stopping you from coming up with your own original solution. I already stuck with my solutions at least 5 times, it's ok, I need fresh ideas :) One of my first ideas was with segment tree and LCM. 1) We calculate order for every element. 2) It is easy to combine 2 segments. order(combined) = LCM(order(segment1), order(segment2)) 3) But it hard to do multiplication. If we multiply by m, we cannot just do order=LCM(order(m), order(segment)). Counterexample: p=17 segment=[2] order(segment)=8 m=2 after multiplication segment=[4] order(segment)=4 4 != LCM(order(2), order(segment)) = 8 I am trying to find a way how to express segment of any length in a short way (lets call it segment_data), so it has next properties: 1) I can calculate order quickly 2) I can create multiplication procedure over segment_data 3) Multiplication over segment_data leads to the same order as multiplication over raw segment 4) I can combine 2 segment_data into 1 (so I can build segment tree) If segment_data is just order of a segment, I cannot make it work (example above). Property 3 is not working. My last idea was to use segment_data = array of 2 elements (I understand I was not very clear in first post, it is confusing even for me). I found next: there are group of segments, that behaves exactly the same for our task. I mean, if: for any i in (1..p-1): order(i * segment1) = order(i * segment2) Then we can replace segment1 with segment2, and nothing changes for our task. I generated groups of such segments for different p. Example: p=17 [6,7,10,12] can be replaced with [3,6] after multiplication by 1..p-1, they lead to the same picture of orders: [16 16 8 16 8 8 8 16 16 8 8 8 16 8 16 16] [6,7,10,11] can be replaced with [6,7], picture [16 16 4 16 4 8 8 16 16 8 8 4 16 4 16 16] When I was investigating behavior of similar segments, I noticed segment of any length can be replaced with segment of length 2. And it will have the same properties. The plan was to have 2 numbers as nodes of segment tree. But I stuck with combining procedure. Edited by author 29.05.2021 18:42 |
| To admins: weak tests | yyll | 1234. Bricks | 28 May 2021 08:08 | 1 |
My accepted program 9380769 fails on the test: 1 3 100 1.1 3 |
| wrong answer | Freddy | 1409. Two Gangsters | 26 May 2021 02:52 | 5 |
why wrong answer? #include"iostream" int main() {
int banki=10; int Garry,Larry; std::cin>>Garry>>Larry; std::cout<<banki-Garry<<" "<<banki-Larry; return 0; } because its wrong - int banki=10 Why this solution is wrong? #include <iostream> using namespace std; int main() { int herry; int larry; int all; cin >> herry; cin >> larry; all=herry+larry-1; herry=all-larry; larry=all-herry; cout << herry << " " << larry; return 0; } Edited by author 03.07.2013 01:45 =) Do you know math? Code: all=herry+larry-1; herry=all-larry; larry=all-herry; Math: all=herry+larry-1; herry=all-larry=herry+larry-1-larry=herry-1; larry=all-herry=herry+larry-1-(herry-1)=larry; Edited by author 25.09.2013 18:28 actually the twist is in the number of total canes. Edited by author 26.05.2021 02:53 Edited by author 26.05.2021 02:53 |
| It's a waste of time! | Celebrate | 1220. Stacks | 24 May 2021 18:43 | 1 |
I spent 3 hours on it.But I find it is expected to use "short" at last!!! |
| Why I get WA at test 10 | Walker | 1977. Energy Wall | 24 May 2021 17:14 | 1 |
I use Segment tree.I can't find anything wrong in my code.Why? |
| Help | Liu Qi | 1557. Network Attack | 23 May 2021 01:19 | 2 |
Help Liu Qi 9 Jan 2010 06:04 I always get a wrong answer on test 11,who can help me? Re: Help Maydell Anton 23 May 2021 01:19 This small test helped me to move from WA on test 11 to AC. 3 4 3 2 1 3 2 1 1 2 ans: 1 |
| Помигите понять ошибки | Romanchillihotpepper | 1910. Titan Ruins: Hidden Entrance | 22 May 2021 16:54 | 2 |
#include<iostream> int main() { int32_t a,c=0,c1=0,d=0; std::cin>>a; int32_t b[a]; for(int g=0;g<a;g++){ std::cin>>b[g]; } for(int g=1;g<a-1;g++){ c=b[g-1]+b[g]+b[g+1]; if(c>c1) {c1=c;d=g+1;} } std::cout<<c1<<" "<<d; } У меня код не выдает ошибок на моем Кодеблоке, тут же выдает следующее: solution(6): error C2131: expression did not evaluate to a constant solution(6): note: failure was caused by a read of a variable outside its lifetime solution(6): note: see usage of 'a' solution(8): warning C4552: '>>': result of expression not used Дело в том, что запись "int32_t b[a];" не стоит использовать, когда в квадратных скобках стоит переменная, которая вводится с клавиатуры (не является константой). Для этого нужно использовать запись "int32_t* b= new int32_t [a];", попробуйте заменить в шестой строке. |
| Found funny formula solution :-) | LuckyCat | 1197. Lonesome Knight | 21 May 2021 06:40 | 2 |
#include <iostream> using namespace std; int main() { int count; cin >> count; while (count--) { char x, y; cin >> x >> y; float a = (x - 'a') - 3.5; float b = (y - '1') - 3.5; cout << trunc(1.143 * trunc(1.2 * (6 - trunc((a * a + b * b) * 0.2f)))) << endl; } } #include <iostream> using namespace std; int main() { int count; cin >> count; while (count--) { char x, y; cin >> x >> y; float a = abs(abs((x - 'a') - 3.5) - 1.0) - 0.5; float b = abs(abs((y - '1') - 3.5) - 1.0) - 0.5; cout << trunc(1.143 * trunc(1.2 * (6-a-b))) << endl; } } |
| It seem like that the lenth of the words is greater than 15? | zwqzwq | 1542. Autocompletion | 21 May 2021 04:34 | 2 |
I set the length of my array to 15 then got WA at #14 while I set16 then I got AC But I dont know why,could anyone help me? |