|
|
Common Boardwhat in test #5? Numbers of Haters can be placed in non-ascending order. After I started checking "1" not only at first position, I got AC what about ternary search in this task? Edited by author 01.10.2020 22:01 Well I tried to do so but got wa4. I also looked at that guy's solution where he just takes the average of all p[i]. And I still cannot understand why it's right bcz, like, it's squared distance not just linear... Edited by author 29.07.2022 12:21 It's because of the first derivative. I tried it, and get WA4. I suspect I have a bug but idk where. I did some more digging. For those interested, try running your ternary search against the following test case (and then compare with the avg approach): ``` 20 9 8 5 12 5 6 89 45205 3554 1585 554422 654235 545324 548835 456432 804654 234758 444 5668 56435 ``` This in both cpp and python gives the wrong answer. By switching to the `Decimal` library in python, I was able to move past 4, and get TLE on 5. Using gmp in cpp might get you to AC, but I think the takeaway here is to only use ternary search when you can set the problem up to have an answer close to 0. please consider very small cases First i tried to solve this problem using int64 (long long) , i got WA6. Then i used long number theory to solve this problem and i got AC!) Good luck! what's that "long number theory" ? i think we need to switch to python. Yeah! Just use Python and it will be accepted! I think it's time to start to learn Java, just some simple things(like input and output) and BigInt. It could probably help me in those long arithmetics case. Problem can be reduced to edges in complete graph: Given no. of edges, what is the max no. of vertices in a complete graph? del Edited by author 20.02.2024 17:47 Я просто накидал кучу каких-то непонятных оптимизаций, и оно почему-то зашло //please tell me what's wrong, cause i cant understand... #include <bits/stdc++.h> #include<fstream> #define all(a) (a).begin(), (a).end() #define ll long long #define sz size #define dbl double #define vll vector <ll> #define INF LLONG_MAX #define uniq(x) x.resize(unique(begin(x),end(x))-begin(x)) #define forik(i,m,n) for(ll i=m;i<n;++i) #define re return using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(); vll numbers; ll num; while (cin >> num) { numbers.push_back(num); } for (ll i = numbers.size() - 1; i >= 0; i--) { dbl nek = sqrt(numbers[i]); cout << fixed << setprecision(4) << nek << endl; } re 0; } #include <iostream> #include <stack> #include <cmath> using namespace std; int main() { stack<double> root; double input;
while(cin >> input) { root.push(sqrt(input)); }
while(!root.empty()) { cout << root.top() << endl; root.pop(); }
return 0; } Here your first input while is going infinnity. You have to stop it. 435 981 301 -384 -1 345 0 Correct answer: 371.78 789.08 thanks for the test found a mistake ( ˘ ³˘)♥︎ worked at least two months.... I think it is a hard problem,harder than some rating>1e4 problems... How did you get the skill to solve such a hard problems? I know generic patterns to effective skill training Interested in particular case Edited by author 08.11.2017 21:17 Just stop solving easy problems,and trying harder one.. I start solving hard problems since year 2010 practicing at http://poj.org solving AC<100 problems and at year 2013 I start solving topcoder Div I 1000pts.. later I found codeforces and start solve fewest AC problems.. There are also some Chinese oj hardest problems is very hard such like http://www.lydsy.com/JudgeOnline/ http://uoj.ac/ Yeah, solving hard is very helpful, I felt it At some point I noticed that I am just not able to solve some harder problem Because it takes very much time to solve So even if trying whole day then cannot solve Maybe whole week is enough But very rarely have an opportunity to solve a problem the whole week Typical have only three hours per day But it's at cost of sacrificing important things So I feel like I cannot improve further Yeah, solving hard is very helpful, I felt it At some point I noticed that I am just not able to solve some harder problem Because it takes very much time to solve So even if trying whole day then cannot solve Maybe whole week is enough But very rarely have an opportunity to solve a problem the whole week Typical have only three hours per day But it's at cost of sacrificing important things So I feel like I cannot improve further you can choose some easier than hardest problems but harder than medium problems if you don't have enough time to practice On spoj.com I have lot of tasks in my TODO list... Why do you consider it a hard problem? It felt quite straightforward to me Timus has very few constructive problems (at least with difficulty >= 2000), so this problem may seem hard compared to others if constructive problems are not your strong point Bruteforce all short numbers (i. e. length <= 3) and feed them to both input and output automata, then compare. Here are some useful tests: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 0 1 0 1 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 8 3 0 1 0 1 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1. Use scanf/printf instead of cin/cout 2. Use make_heap, push_heap and pop_heap instead of priority_queue 3. Use C-style array instead of vector 4. Do not allocate n elements for an array #include<stdio.h> int main() { int i,n,sum; scanf("%d",&n); if(n>0) { for (i=1;i<=n;i++) { sum=sum+i; } printf("%d",sum); } if(n<0) { for (i=n;i<=1;i++) { sum=sum+i;} printf("%d",sum);} else if(n==0){ printf("not applicable");} } If you are getting an error on test 5 then use double instead of float. Если у вас ошибка при 5ом тесте, используйте переменные double вместо float. Any hints about test 7? I had WA7 when I computed maximal rotation angle incorrectly. I kept getting wrong answer in test#3. What should I do? I will post one if I solve it. There are n subway stations on a subway line, numbered from 1 to n. The distance between the ith station and the i+1th station is s_i, which means the train need s_i minutes to drive from the ith station to the i+1th. There are trains driving from 1 to n and trains driving from station n to station 1. The trains driving from station 1 to station n departs every d minutes at station 1 and the first one of that departs at d1 minutes. Similarly, The trains driving from station n to station 1 departs every d minutes too at station n and the first one of that departs at dn minutes. However, in this problem the trains are considered not to stay at any station, just drive past A vistor is going to visit every station. He starts from station t. To visit a station, he has to take a train and get off at that station. It takes him 1 minutes to visit a staion, so that he cannot take the train he get off just now. The station t is considered visited. After all visits he need to return to station t. You are going to make a plan for him so that the time cost is minimized. The time cost is calculated as (the time he has visited all stations and gets off a train to station t - the time he departs--getting on a train at station t (can be any train)). Output such time in minutes. Input n s_1 s_2 ... s_(n-1) t d d1 dn Edited by author 24.01.2024 09:02 Explanation of the sample: One possible solution. Take the train to n at 5 and get of to station 3 at 12. Then take the train to 1 at 13 and get of to station 1 at 25. Then take the train to n at 28 and get of to station 2 at 33. It costs 33-5=28 Edited by author 24.01.2024 09:05 |
|
|