| Show all threads Hide all threads Show all messages Hide all messages |
| Stack Overflow | Night | 1553. Caves and Tunnels | 17 Jun 2021 20:27 | 3 |
Please I got Crash(Stack Overflow), I implemented my first heavy-light descomposition and tried this problem, but I got this. I got AC, I had to convert the DFS to BFS, to evade the StackOverflow. Edited by author 02.11.2011 04:45 Edited by author 02.11.2011 07:20 Edited by author 02.11.2011 08:20 {$m 100000000000000000000} You can use "G++ 9.2 x64" language to avoid it |
| Newton | yyll | 1475. Ryaba Hen | 17 Jun 2021 14:46 | 1 |
Sir Isaac Newton is important to this problem. In TWO different ways. |
| WA 28 ??? | Aleksander | 1346. Intervals of Monotonicity | 16 Jun 2021 21:18 | 4 |
Why WA 28?I don't understand. Here is my code: program gjkh; var a,b,ch,n,i,kol,sh,fir,sec,thi:longint; m:array[1..100001]of longint; flag:boolean; begin read(a);readln(b); n:=0; while not seekeof do begin read(ch); if (n=0)or(m[n]<>ch)then begin n:=n+1; m[n]:=ch; end; end; flag:=true; kol:=1; for i:=1 to n do begin if (i=1)then fir:=m[i] else begin if (flag=true)then begin sec:=m[i]; flag:=false; end else begin thi:=m[i]; if ((thi-sec)*(sec-fir)>0)then begin fir:=sec;sec:=thi; end else begin fir:=thi; kol:=kol+1; flag:=true; end; end; end; end; writeln(kol); end. 1 5 -100000 500000 -70000 800000 -80000 answ: 3 Edited by author 01.02.2010 18:44 Input numbers must not exceed 100000 by absolute value. why is 3, because there are 4 intervals? |
| WA#4 | Shohruh | 1927. Herbs and Magic | 16 Jun 2021 15:08 | 1 |
WA#4 Shohruh 16 Jun 2021 15:08 Edited by author 16.06.2021 15:21 Edited by author 16.06.2021 15:22 |
| what does that mean? " which are the number of the immediate superior" | Giorgi Pataraia [Tbilisi SU] | 1890. Money out of Thin Air | 15 Jun 2021 23:01 | 2 |
It means, each employee (except the director) has only one immediate superior. If employee A is superior to employee B, and employee C is superior to employee A, then C->A->B. Both C and A are superior to B, but only A is B's immediate superior. |
| weak tests | Vit Demidenko | 1099. Work Scheduling | 15 Jun 2021 21:00 | 1 |
|
| Getting MLE for this:|| | Reza Gharaghani | 1306. Sequence Median | 15 Jun 2021 13:14 | 1 |
#include<algorithm> #include<cstdio> using namespace std; #define MAX_N 250000 int n, i, t1, t2; int *heap; int main(){ scanf("%d", &n); heap = new int[n/2+2]; for(i = 0; i < n/2+1; ++i){ scanf("%d", heap+i); push_heap(heap, heap+i+1); }
for(i = 0; i < n/2-(n+1)%2; ++i){ scanf("%d", heap+n/2+1); push_heap(heap, heap+n/2+2); pop_heap(heap, heap+n/2+2); } if(n%2){ printf("%d.0\n", heap[0]); }else{ t1 = heap[0]; pop_heap(heap, heap+n/2+1); t2 = heap[0]; if((t1+t2)%2){ printf("%d.5\n", t1/2+t2/2); }else{ printf("%d.0\n", t1/2+t2/2+t1%2); } } delete[] heap; return 0; } |
| #WA3 need test case | jim | 1788. On the Benefits of Umbrellas | 15 Jun 2021 03:30 | 2 |
#include <iostream> #include <algorithm> using namespace std; int main() { int i,j,k,l,ii; int m,n; int girls[101]; int boys[101]; int count = 0; int upsets = 0, girlUpsets = 0, boyUpsets = 0, currentUpsets = 0; int happyGirls = 0; int chooseGirl = 0, chooseBoy = 0; for (i = 0; i <= 100; i ++) { girls[i] = 0; boys[i] = 0; }
cin >> n >> m; //n girls m boys for (i = 1; i <= n; i ++) { cin >> girls[i]; } for (j = 1; j <= m; j ++) { cin >> boys[j]; } count = min (m, n); //计算无配对upset值 for (i = 1; i <= n; i ++) upsets += girls[i]; happyGirls = 0;
for (i = 1; i <= count; i ++)
{ for (j = 1; j <= n; j ++) for ( k = 1; k <= m; k ++) { girlUpsets = 0; boyUpsets = 0; //计算girl upset值 for (l = 1; l <= n; l ++) { if (l != j) { girlUpsets += girls[l]; } } //计算boy upset值 for (l = 1; l <= m; l ++) { if (l != k) boyUpsets += boys[l] * (happyGirls + 1); //cout << "werqe: " << boys[l] << '\t' << boyUpsets << endl; } currentUpsets = girlUpsets + boyUpsets; if (currentUpsets < upsets) { upsets = currentUpsets; chooseGirl = j; chooseBoy = k; } } if (chooseBoy != 0 && chooseGirl != 0) { happyGirls ++;
//删除第chooseGirl个girl for (ii = chooseGirl; ii <= n - 1; ii ++) girls[ii] = girls[ii + 1]; n --;
//删除第chooseBoy个boy for (ii = chooseBoy; ii <= m - 1; ii ++) boys[ii] = boys[ii + 1]; m --; } } cout << upsets << endl; return 0; } |
| Hint | yyll | 1509. Domino Recognition | 14 Jun 2021 17:23 | 1 |
Hint yyll 14 Jun 2021 17:23 Find a robust feature to distinguish different bones with same total dots. This really is an easy problem once you find that feature. |
| 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 |
|