|
|
Общий форумwrite 7 test. Please. Did you find solution for 7th test? Test 7 please. Edited by author 27.11.2019 12:53 Can someone send test 6 please? Thanks Yes i can, but you so glup for this Edited by author 26.11.2019 11:33 Как удалить тему? Edited by author 26.11.2019 11:32 Edited by author 26.11.2019 11:32 I used sqrt-decomposition and got AC in 358ms My idea was like this: 1. Keep an array of the elements we have so far 2. For each sqrt-size block of the array compute the GCD 3. To insert an element: append it to the array and update its block 4. To remove an element: swap the element to be deleted with last element (I used a set of pairs<value, index> to get them quickly) and update their blocks Insert (sqrt n) Delete (sqrt n) O(q sqrt n) where n is number of elements in the array Do you mean that after every insertion, we have to update the block containing the element as well as the block size? If block size is also updated, then shouldn't we have to update the whole array we've had so far? I used sqrt too but in a slightly different way from yours. I read all the queries and store all the values of query + to an array, decide the block size and compute GCD for each block. Then I loop the array again to answer the queries. If it is query +, I simply increase the counter x and call GCD(a[1..x]) (because I completely computed GCD of all blocks before). If it is query -, I erase x in the present array. Specifically, I recompute the GCD of the block without erased value x. This way caused me TLE on test #17, though :(( please can anyone tell me what is the test of 5. #include <iostream> #include <string> using namespace std; int main() { int n,g=2; cin >> n; for(int i = 0; i < n; i++) { string a; cin >> a; if(a.length() > 4 && a.substr(a.length()-4,a.length()-1) == "+one") g+=2; else g++; } if(g == 13) cout << 1400; else cout << g*100; } I can't understand what's wrong with my code is my algorithm wrong? or what? my code: #include <stdio.h> #include <math.h> double x[102],y[102]; double dist(int i, int j){ int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]); if(d1==0) return (d2); else if(d2==0) return (d1); else return sqrt(d1*d1 + d2*d2); } int main(){ int i; double n,s=0,r,pi=2*acos(0); scanf("%Lf %Lf",&n,&r); for(i=0;i<n;i++) scanf("%Lf %Lf",&x[i],&y[i]); for(i=1;i<n;i++) s+=dist(i,i-1); s+=dist(0,n-1); s+=2*pi*r; printf("%.2Lf\n",s); return 0; } if someone can help me I would appreciate very much thanks! Your algorithm is right. But it seems to me very strange, that d1 and d2 in your code are integers, while x and y are not. double x[102],y[102]; double dist(int i, int j){ int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]); ...} And double n seems strange to me too. Test #4: 3 1.2 12.24 13.34 0.00 24.75 -33.36 70.12 Solution: 153.41 thank you both of you guys :D!!!!!! (and sorry for my bad english :$) I finally got ac, just some stupid and silly mistakes! the answer should be 149.64 isn't it??? where am I wrong? . Edited by author 20.11.2019 17:29 Edited by author 17.11.2019 11:13 8 A B C D E F G H 6 A HIT B IN HEAD A HIT C IN HEAD A REVIVE B B REVIVE C A HIT D IN HEAD C REVIVE D Can anyone help me? I have no idea about how this test looks like. Any hints or tests? I have WA 30, what did you do to AC? Ok, I got AC after lots of WA 30 attempts by iterating over the input in the reversed order, which makes no sense to me. My current best guess is that test #30 is broken, so there are at least two correct answers and it accepts only one of them as correct. Of course, my algo can delete edges in different order depending on the order in which it iterates over them, but I'm pretty sure it always removes the maximum number of edges. So, when user starts looking for words, my program immediately writes the answer. Maybe that's why it isn't correct. For example: user -> 2 user -> ab program -> abc user -> xz program -> xzy We can qsort(n) and enumeration to solve it. Notice that n is a prime.There are 2500 primes under 32767. Enumeration can solve this problem. And every ask have mostly 2 answers.最多2个解 There are 3512 primes under 32767. I wrote the solution and had the correct answers on test cases, but i have wa1. Can someone help me or give advice? This is my solution: #include <iostream> #include <iomanip> #include <cmath> #include <algorithm> #include <numeric> #include <set> #include <map> #include <vector> #include <string> #include <cstring> #include <cstdlib> using namespace std; #define task void print(int array[], int n) { for (int i = 0; i < n; i++) { cout << array[i] << ' '; } } void optimization() { cin.tie(nullptr); ios_base::sync_with_stdio(false); } int factorial(int x) { int a = 1; for (int i = 2; i < x + 1; i++) { a *= i; } return a; } #ifdef task int main() { optimization(); int n, m; cin >> n >> m; int **field = new int *[n]; for (int i = 0; i < n; i++) { field[i] = new int[m]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> field[i][j]; } } int q; int k; int x = 0; int y = 0; int max_drop = -1; int part_sum = 0; int move_to_right = -1; cin >> q; for (int quest = 0; quest < q; quest++) { cin >> k; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { move_to_right = k + 1; part_sum = 0; for (int down = i; down < i + k + 1; down++) { for (int right = j; right < j + move_to_right; right++) { if (down < n && right < m) { part_sum += field[down][right]; } } move_to_right--; } if (part_sum > max_drop) { max_drop = part_sum; x = i + 1; y = j + 1; } } } cout << max_drop << ' ' << x << ' ' << y << endl; max_drop = -1; } return 0; } #endif upd: Before I used scanf and got wa1. Now with cin // cout i have tle17. Edited by author 14.11.2019 22:47 In the example 2 2 3, z==5. Why do everybody say that z==2? Thank you, dear! You are my saver! Thank. Now everything stopped at MLE есть ли способы на питоне обойти прожорливость памяти? I also have WA10/ Help Someone! I m too :\ 9 8 2 0 4 3 0 0 5 6 0 0 0 0 9 0 7 0 1 correct answer 4 some Test Please !!! 9 8 2 0 4 3 0 0 5 6 0 0 0 0 9 0 7 0 1 correct answer 4 |
|
|