| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| hint | ASK | 1956. Сигнальные костры | 24 апр 2018 21:50 | 1 |
hint ASK 24 апр 2018 21:50 AC with 72 iterations of ternary search of line normal angle starting with [-π/2, π/2]. For some reason, [0,π] does not work. |
| Can rectangles be nested? | Sirko | 1170. Desert | 24 апр 2018 19:31 | 3 |
Edited by author 26.02.2015 13:30 Edited by author 26.02.2015 13:30 No, the problem statement makes no sense for nested rectangles. |
| Question to solvers, authors (warn: spoiler) | Sirko | 1170. Desert | 24 апр 2018 19:30 | 2 |
Can you guys provide me with a brief math proof that searched direction always contains at least one rectangles vertex (that is, no need to search for it between those rays made from vertexes coordinates)? Thanks. In a small enough neighborhood of a line that does not pass thru one of the vertices, the distance traveled inside rectangle is smaller on one side and larger on the other, thus the distance on the line is not smaller/larger than in the neighborhood. |
| Must the optimal line "L" pass at least one vertex of the N rectangles.If so,then how can improve it.If not,I find it's impossible to solve it. | Huang Yizheng | 1170. Desert | 24 апр 2018 19:20 | 4 |
yes ASK 24 апр 2018 19:20 Yes, there is an optimal line that passes thru one of the vertices (remember, that there are 4N vertices, not 2N :-) |
| hint | ASK | 1265. Зеркало | 24 апр 2018 16:37 | 1 |
hint ASK 24 апр 2018 16:37 Do not fight with precision, use fractions in Python 3. |
| efficient idea | Cuac!++ | 1065. Граница | 24 апр 2018 00:12 | 3 |
Hi!, i have gotten AC in this problem, but i have 0.093 secs, and im not well ranked on the best solutions table, i think the difficult part of this problem is to see which triangle have historical monuments inside, i did it with an O ( logM * M * N ) approach, do anybody have something better? i really would like to know how to get 0.015 secs or less. Thank you very much! Eric ( Cuac!++ ). Hi. I've got 0.015 secs. http://acm.timus.ru/status.aspx?author=34678&num=1065&refresh=noMy algo woks O(M*N + N^3). Here is my idea: i don't look which triangles contain historical monuments. i calculate which sequences of vertexes can we delete and what length we win if we do so. Then i find optimal way of selecting these sequences of vertexes. Do you need more details? Nope, it is at least O(M*N*log(N) + N^3), but with N~50 it is not noticeable. For each tower check how many towers can be skipped, that is for each possible skipping length check if there are monuments ccw to the chord: O(M*N^2), but can be O(M*N*log(N)) with binary search. For each length and each start calculate minimal perimeter on the way from start to start+length trying all intermediary towers: O(N^3). For each triple of towers that form a triangle, sum minimal perimeters and find the global minimum: O(N^3). |
| For everyone who has WA7 | olpetOdessaONU [1 2/3] | 1354. Палиндром. Он же палиндром | 23 апр 2018 13:46 | 4 |
Try this test: a Your output should be: aa Good luck! Thank you! You is good man! |
| WA5 | Farhodbek_tuit_kf | 2056. Стипендия | 23 апр 2018 10:20 | 2 |
WA5 Farhodbek_tuit_kf 5 май 2015 16:47 Can someone give 5<sup>th</sup> test? I got WA5; |
| Had anyone problems with test #10? | tereshinvs | 1281. River Basin | 22 апр 2018 17:31 | 5 |
is the first sample correct? isn't a test from picture? and then there is not river basin with area 16 in the table. it is correct. Edited by author 30.03.2011 00:29 AC using convex polygon algo from e-maxx.ru. I don't know where i was wrong... Edited by author 15.05.2012 22:52 This is the first test where the convex_hull fails if it uses integer as a result of vector product. |
| if you have WA25 | WA24 (Java | C#) | Maxm | 1612. Трамвайный форум | 21 апр 2018 20:22 | 1 |
String symbols = "`~!№*@#$%^&*()-_=+\\|[{]};:'\",<.>/?в„– \n\r\t"; ;) |
| This is a good test | 10100 | 1580. Долги декана | 21 апр 2018 07:52 | 1 |
6 7 1 2 3 2 3 3 3 4 4 1 4 4 4 5 5 2 6 3 6 5 3 |
| Solving using the height of last step | Gokul | 1017. Лестницы | 21 апр 2018 01:10 | 1 |
Hi All, Just want to share my experience solving this problem. I did it like this let the i be the number of bricks available and j be the height of the last step. S[i][j] = sum(S[i-j][:j]) + (1 if (i-j) < j else 0) So basically all i am doing is the number of stairs with i bricks and height j is also the same number of stairs with i-j bricks and max height of j - 1(hence the array stops at index j) and one more if i - j bricks are less than height j. There might be more slick solution avaiable, but this worked for me :) Edited by author 21.04.2018 01:11 |
| Can you give some tests? | NickC8 | 1686. Фотоэлектрический звездолёт | 20 апр 2018 01:52 | 3 |
Can you give some tests? The stars coordinates aren't natural numbers? Why precision of 10^-5 is needed? Should the algorithm ignore cases when scalar product of normal vector of the plane and "star"-vector is negative (the angle between vectors will be 90<x<270 so star's rays won't reach solar battery of esp. this plane)? Integer output also works, but you need int64_t. Note that it is not enough for normal/star angle to be less than pi/2, you also need to have correct normal -- the one that is opposite to the fourth vertex. |
| the real hint | ASK | 1719. Убей Шайтан-босса | 19 апр 2018 22:23 | 1 |
To find the shortest path from point O to lines AB and CD (in that order) one needs to consider three possibilities, namely projection from O to CD (if it intersects AB); projection on CD of the reflection of O thru AB (if it intersects AB); intersection of AB and CD. |
| Solution using SQRT_DECOMPOSITION | iOli | 1126. Магнитные бури | 19 апр 2018 22:18 | 1 |
#include <bits/stdc++.h> using namespace std; int query(int l, int r, vector<int> bucket, vector<int> v) { int n = v.size(); int bkt_sz = sqrt(n); int bkts = bucket.size();
int lb = l/bkt_sz; int rb = r/bkt_sz; int lbp = l%bkt_sz; int rbp = r%bkt_sz;
int retval = -1;
if (lb == rb) { for (int i=lb*bkt_sz+lbp; i <= lb*bkt_sz+rbp; i++) retval = max(retval, v[i]); return retval; }
for (int i=lb+1; i < rb; i++) retval = max(retval, bucket[i]);
for (int i=lb*bkt_sz+lbp; i<n; i++) { if (i >= (lb+1)*bkt_sz) break; retval = max(retval, v[i]); }
for (int i=rb*bkt_sz; i <= rb*bkt_sz+rbp; i++) { retval = max(retval, v[i]); }
return retval; } int main() {
int k; cin >> k;
vector<int> v;
while (true) { int a; cin >> a; if (a == -1) break; v.push_back(a); }
int n = v.size(); int bkt_sz = sqrt(n);
vector<int> bucket;
int count = bkt_sz; int max_value = -1; for (int i=0; i<n; i++) { if (count == 0) { count = bkt_sz; bucket.push_back(max_value); max_value = -1; } count -= 1; max_value = max(max_value, v[i]); }
bucket.push_back(max_value);
for (int i=0; i+k-1 < n; i++) { cout << query(i, i+k-1, bucket, v) << endl; }
} Edited by author 19.04.2018 22:19 |
| С# | TheVoold | 1785. Трудности локализации | 19 апр 2018 01:54 | 2 |
С# TheVoold 18 апр 2018 23:36 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { int x; x = Convert.ToInt32 (Console.ReadLine()); if ((x > 1 & x <= 4) { Console.WriteLine("few"); } if (x > 5 & x<= 9) { Console.WriteLine("several"); } if (x > 10 & x <= 19) { Console.WriteLine("pack"); } if (x > 20 & x <= 49) { Console.WriteLine("lots"); } if (x > 50 & x <= 99) { Console.WriteLine("horde"); } if (x > 100 & x <= 249) { Console.WriteLine("throng"); } if (x > 250 & x <= 499) { Console.WriteLine("swarm"); } if (x > 500 & x <= 499) { Console.WriteLine("zounds"); } if (x > 1000) { Console.WriteLine("legion"); } } } } Да что тут не так? Edited by author 18.04.2018 23:36 Edited by author 18.04.2018 23:37 Re: С# Oleg Baskakov 19 апр 2018 01:54 У вас везде > вместо >=. Ну и тут отдельная ошибка if (x > 500 & x <= 499) |
| this problem can be set n,m<=1000 | Shen Yang | 1411. Рыцари 40 островов | 18 апр 2018 13:51 | 1 |
there is O(n*m) D&C algorithm... similar with ural 1674 and ural 1596 |
| oh I know how to solve in O(1) | Shen Yang | 1815. Ферма в Сан-Андреасе | 18 апр 2018 11:17 | 12 |
it is just extend of fermat point, the angle is 2*pi/3 if it is fermat point in this problem three angles are acos((c1*c1-c2*c2-c3*c3)/(2*c2*c3)),acos((c2*c2-c1*c1-c3*c3)/(2*c1*c3) and acos((c3*c3-c1*c1-c2*c2)/(2*c1*c2)) how to get it ,just let two partial derivative to be zero,and square and add two equtation we can get it ,it is easy I can find three angles, but not optimal point. Three angles allow us to assume that the point depends of some angle (phi) and we must find min F(phi). How you solve in O(1)? Give me hint if we get three angles assume optimal point is O,and triangle is ABC, then let angle OAB==theta, we can get some equations using sine theorem and divide two sine theorem euations we can solve tan(theta) then problem is solved Thanks. I forgott sin theorem. Now i have WA2 (I search point in A1A2A3) Triangle A1A2A3 and optimal point is X. XA1A3=phi, XA2A3=alfa12-phi-A3 cos(alfa12)=(c3*c3-c1*c1-c2*c2)/(2c1*c2) ... A3X/sin(phi) = A1A3/sin(alfa13) A3X/sin(alfa12-phi-A3) = A2A3/sin(alfa23) => A1A3/sin(alfa13) sin(phi) = A2A3/sin(alfa23) * [sin(alfa12-A3) cos(phi) - cos(alfa12-A3) sin(phi)] tan(phi/2) = t a*2t/(1+t*t) = b * (c*(1-t*t)/(1+t*t) - d*2t/(1+t*t)) => phi = 2atan(t) ans res=XA1*c1+XA2*c2+XA3*c3 In the second test the optimal point on the side of the triangle? Can there be a test where A1=A2 or A1=A3 or A2=A3? Edited by author 18.04.2018 11:18 wa on test case 2 is probably because there are two or three same points you must to consider deleted Edited by author 18.04.2018 11:51 Hi! Your program on test 1 0 0 100 100 200 200 30 45 78 gives 15273.50647362942600000000 but right answer 14849.242404917499000 (optimal point is A3: A1A3*c1+A2A3*c2). Is the optimal point always inside the triangle or on the side? Yes,admin please add this tests, and make some more similar tests... there are two points A[i]>=alpha[i] in this test ,so must compare these points and get min... Edited by author 03.04.2018 07:41 Edited by author 03.04.2018 07:44 Edited by author 16.04.2018 19:00 Optimal point is O. 1) O=A or O=B or O=C 2) We have triangle ABC with 0<A,B,C<pi; We know cos(AOB), cos(AOC), cos(BOC). Let z1=(c3*c3-c1*c1-c2*c2)/(2*c1*c2), z2=(c2*c2-c1*c1-c3*c3)/(2*c1*c3), z3=(c3*c3-c1*c1-c2*c2)/(2*c1*c2). If |z1|>1 or |z2| >1 or |z3|>1 => optimal point is A or B or C Let |zi|<=1, i=1..3 teta=AOB. Theorem sin: BO/sin(teta) = AB/sin(AOB) = AO/sin(teta+AOB) = k1 and CO/sin(A-teta) = AC/sin(AOC) = k2. =>AO=k1*sin(teta+AOB), BO=k1*sin(teta), CO=k2*sin(A-teta). (*) We want find min{f(teta)=c1*AO+c2*BO+c3*CO} on 0<teta<A. Derivative f: cos(teta)*[c1*k1*cos(AOB)+c2*k1-c3*k2*cos(A)]+sin(teta)*[-c1*k1*sin(AOB)-c3*k2*sin(A)]=0 or cos(teta)*a+sin(teta)*b=0, cos(teta)=+=sqrt(sqr(b)/(sqr(a)+sqr(b)). Then we check 0<teta<A and update ans. Where is mistake? I think mistake is (*) but I can't understand why. P.S. We can use Theorem cos with BOC and get equation with teta, but this equation is big and not obviously that we find solution. P.S. Your code not help me. Edited by author 16.04.2018 19:08 Does your result O point satisfy cos(AOB)==z1 cos(AOC)==z2 cos(BOC)==z3 ? if it is satisfy I think you can AC Now AC. (*) is wrong because F(teta) not function!!! P.S. All the time I incorrectly have considered the case when the point is lying on one of the sides of the triangle (in this case sin(AOB) or sin(AOC) or sin(BOC)=0). I add this and AC: if(fabs(sin(AOB))<eps && fabs(sin(AOC))<eps || fabs(sin(BOC))<eps) return inf; if(fabs(sin(AOB))<eps) {
CO=AC*sin(A)/sin(AOC); AO=AC*sin(A+AOC)/sin(AOC); BO=BC*sin(C-(pi-A-AOC))/sin(BOC); return c1*AO+c2*BO+c3*CO; } if(fabs(AOC)<eps) { BO=AB*sin(A)/sin(AOB); AO=AB*sin(A+AOB)/sin(AOB); CO=BC*sin(B-(pi-A-AOB))/sin(BOC); return c1*AO+c2*BO+c3*CO; }
P.S. Delete your code, but keep the hints. |
| Memory Limit Exceeded!!! Why?I don't understand | Scaletta_Z | 1014. Произведение цифр | 18 апр 2018 00:49 | 2 |
Edited by moderator 23.08.2020 01:12 Did you try some big prime number? Like 777777773. |
| test case 9 is invalid | Shen Yang | 1438. Time Limit Exceeded | 17 апр 2018 21:52 | 3 |
there is a line which isn't token "end" and has no ':' character and there is only one nonempty token.. I use OLE test it must be wrong test... it is not include in the description so admin please fix problem description or delete this test problem description is incorrect there are far more than 2000 lines, and one token is far more than 50 characters.... |