Common Board| Show all threads Hide all threads Show all messages Hide all messages | | what does that mean? " which are the number of the immediate superior" | mes | 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 Re: WA 25 Andrew Sboev [USU] 28 Apr 2012 18:33 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!!! |
|
|