| Show all threads Hide all threads Show all messages Hide all messages |
| Why this code don't run 🤔🤔 | NurbolatTurgynbekov | 1016. Cube on the Walk | 22 Jul 2018 20:51 | 1 |
|
| No subject | dxm439 | 2051. Physics | 22 Jul 2018 08:12 | 1 |
|
| The problem is easily solvable without segment tree. | Jorres | 1019. Line Painting | 21 Jul 2018 14:54 | 2 |
Also pay attention to the fact that according to the example - segment is (a;b]. I used this approach and got accepted. (O (N*N) btw :) ) Yes. Compressing coordinates and painting segments straightforwardly is enough. |
| AC.some hint: | Neumann | 1258. Pool | 21 Jul 2018 14:38 | 3 |
think the four edges as four mirror...... :) Just compute total chanhe in X and Y and then output hypotenuse. It can be shown pretty intuitively by reflecting triangles, thanks for the hint. |
| how to solve this problem | nttjuvwamsncc | 1519. Formula 1 | 21 Jul 2018 12:03 | 4 |
I think this is very interesting and hard problem so who can tell me the solution of this problem what is the author's solution I will tell you the solution because this problem should have time limit of around 3-5 seconds. I struggled for almost two days making that algo suffice all tests, and still I had to precompute an empty 12x12 grid, and my AC solution ran for exactly 1 second :)) Go row-by-row with state representing connected components above. These will be something like 11022, 12021, 10220133, etc... Where 0 stands for no exit from above and 1..n stand for connected component number. Actually, every connected component will have exactly two exits downwards, and they will be placed in stack order. Cases like 1212 are impossible because it would mean that paths 1..1 and 2..2 intersect somewhere above. So, this gives us a way to effectively enumerate all of components using at most 2^2 * 3^10 states. Digit 0 means skip. Digit 1 means start new component. Digit 2 means close last open component (remeber their stack order). First digit can't be 2 and last digit can't be 1. This is enough to keep values about previous and next row with cache of next_x[12] - a matching of exits for each column. Also, don't forget to keep array of indices with non-zero values for previous and the next row, this optimizes things a little as you will run only through reachable states. Once you complete current row, paint everything to find resulting components matching with exits from the row just painted. It can be done via BFS, but I couldn't meet TL with that, so I had to optimize it - all paths are chains, so just walk straight. For the last row a path should be a chain loop covering of all upper exits. Internal transfers should keep all components alive, that is - there must be no loops. This also allows to optimize recursive steps for building current row by remembering last connected upper component connected by "rhhhh..." - so just don't allow closing it towards itself, unless it is the last row. Also, do not forget to skip first and last rows full of **********. Is tracing row-by-row quicker than element-by-element??? Can be solved in less than 0.1s using broken profile dynamic programming. |
| Ford-Fulkerson tl22 | Ibragim Atadjanov (Tashkent U of IT) | 1774. Barber of the Army of Mages | 20 Jul 2018 22:31 | 13 |
I've used Ford-Fulkerson algo and got TL on test 22.(in java) I took in internet one of the best Ford-Falkerson with BFS, based on priority queue and got Ac immidiately(but time is not very good) Could you give me the link to this site please Could you give me the link to this site please TLE? It's really strange. Try to find bug in your code. I accepted this problem using usual Ford-Fulkerson at 0.031 May be the reason of TLE is realization of algo. Or possibly you build graph in some strange manner. Don't use adjacency matrix. Just use list of edges for each vertices. Build bipartite graph. Left part is mages (100 vertices). Right part - is time at which mages would be possibly shave (2000 vertices). Connect i-th mage with ti...ti+si-1 times (1-capacity). Connect source vertex with each mage (2-capacity). Connect each time (0..2000) with target vertex (k-capacity). I'd built the graph as you said. I didn't use adjacency matrix instead I used adjacency list for each vertex. I don't know what to do else. i saw that you had WA on 39. test... i have same problem... if you could say to me what have you done to get AC? there are some anti-bfs tests, try to cheat somehow :) Edited by author 08.04.2011 18:48 My simple BFS implementation of F-F also TLed, but Dinic's modification got AC ford-fulkerson based on simple dfs gives ac in 0.031 let us calc complexity, O(E * F), where E is edge's count, F is flow in huge test E is ~ 2000 * 100 + 2000 + 100 F is ~ 200 so we have ~ 40*10^6 operations multiplied by some constant if use own vectors (not stl-one), based on simple arrays, you'll be ok this problem does not need bfs-flow, 'cause there are 1-weighted edges on the way every time Edited by author 20.08.2011 04:55 Edited by author 12.07.2012 19:25 If you FF algorithm runs slow you can add scaling, either bit-scaling or simple capacity scaling, this alone should be enough to deal with all possible anti-FF networks. |
| O(N^2) solution... | Dima_Philippov | 1416. Confidential | 20 Jul 2018 21:41 | 2 |
What is the O(N^2) solution of this problem? I wrote simply Kraskal & DFS with assimptoty O(E * Log(E) + V * E) and got Accepted in 1.156... I want to know O(N^2) solution of this problem... My 0.093 N square solution: 1) Compute MST with Kruskal in E logE. 2) For each pair of vertices in MST compute dp[u][v] the cost of largest edge on path from u to v. This can be done by calling N depth first searches. DFS runs in O(E) and there is N - 1 edge in a MST. So this step takes (N^2) time. 3) For each edge (u, v) that isn't in a MST try to relax answer with { MST_COST - dp[u][v] + weight(u, v) }. This step is done in O(E). So, the running time of this solution is O(ElogE + E + N^2) = O(N^2). |
| python3 как вводить данные с помощью текстовых файлов? | epoc | 1000. A+B Problem | 20 Jul 2018 21:03 | 3 |
Подскажите, добрые люди, как же сделать так, чтобы не отправлять по сто раз решения на сервер, чтобы узнать работают они или нет.. для этого нужно отлаживать программу с помощью текстовых файлов, как же с ними работать? для паскаля в руководстве написано вот это: var a, b: longint; begin {$IFNDEF ONLINE_JUDGE} assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); {$ENDIF} readln(a, b); writeln(a + b); {$IFNDEF ONLINE_JUDGE} close(input); close(output); {$ENDIF} end. может кто-нибудь написать такую же для python3??? Instead of changing text inside the program you can simply run it and redirect its input or output, for example, run python3 prog.py < input.txt > output.txt If you absolutely cannot use shell then you can redirect input/output by assignment, but remember to remove this part before submission. import sys sys.stdin = open('input.txt') sys.stdout = open('output.txt','w') a=int(input()) print(a+1) Нахуй текстовые файлы. Самый заебатый ввод следующий: numList = list(map(int, input().split())) ans = numList[0] + numList[1] print(ans) |
| What is test 5 ? | pizdec | 1808. Chapaev at the Planet Ocean | 20 Jul 2018 19:10 | 1 |
What answer on test 10 2.0 5 10 0 -1 5 -10 0 1 ? I think answer "Yes" Give me some tests Edited by author 20.07.2018 19:14 |
| WA #3 Why it is not working? | Koloskova Mariia | 2023. Donald is a postman | 20 Jul 2018 14:21 | 3 |
#include<iostream> #include<string> using namespace std; int main() { int n,k=0; char t,s; cin>>n; string a[1001]; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n-1;i++) { t=a[i][0]; s=a[i+1][0];
if((t=='A' || t=='P' || t=='O' || t=='R') && (s=='A' || s=='P' || s=='O' || s=='R')) k+=0; if((t=='A' || t=='P' || t=='O' || t=='R') && (s=='B' || s=='M' || s=='S')) k+=1; if((t=='A' || t=='P' || t=='O' || t=='R') && (s=='D' || s=='G' || s=='J' || s=='K' || s=='T' || s=='W')) k+=2;
if((t=='B' || t=='M' || t=='S') && (s=='B' || s=='M' || s=='S')) k+=0; if((t=='B' || t=='M' || t=='S') && (s=='A' || s=='P' || s=='O' || s=='R'|| s=='D' || s=='G' || s=='J' || s=='K' || s=='T' || s=='W')) k+=1;
if((t=='D' || t=='G' || t=='J' || t=='K' || t=='T' || t=='W') && (s=='D' || s=='G' || s=='J' || s=='K' || s=='T' || s=='W')) k+=0; if((t=='D' || t=='G' || t=='J' || t=='K' || t=='T' || t=='W') && (s=='B' || s=='M' || s=='S')) k+=1; if((t=='D' || t=='G' || t=='J' || t=='K' || t=='T' || t=='W') && (s=='A' || s=='P' || s=='O' || s=='R')) k+=2; }
cout<<k; return 0; } 1 Dumbo --->>> is not working Right Answer is 2 but your answer 0 |
| No subject | Yusufjon | 2023. Donald is a postman | 20 Jul 2018 14:18 | 1 |
Edited by author 27.07.2018 02:09 |
| this is formula of physics | Adhambek | 1800. Murphy's Law | 19 Jul 2018 07:19 | 2 |
w = N/t h = g*t*t/2 this is also if l/2 >= h you must print "BUTTER" and you stop your program else continue |
| Test | Proba | 1800. Murphy's Law | 19 Jul 2018 07:19 | 8 |
Test Proba 3 Nov 2010 18:55 1 1 1 butter 1 1 100 butter 1 1 900 bread 1 1 1000 bread 100 10 1000 butter 1 1 469 butter 1 1 470 bread Why you have 1 1 470 - bread and 1 1 469 - butter? 1 1 469 time = 0.045152364098573095 speed = 7.816666666666666 N = time*speed = 0.352940979370513 angle = 127.05875257338468. So it must be bread; and 1 1 470 time = 0.045152364098573095 speed = 7.833333333333333 N = time*speed= 0.3536935187721559 angle = 127.32966675797611 So for both variants we get bread. Am i not right ? Oh.. Proba, sorry. Now see problem. thank you for tests :) Re: Test Maciej Paprocki 20 Jan 2011 03:25 why you are using speed, you need only angle for which you dont need speed Re: Test Maciej Paprocki 20 Jan 2011 04:11 sorry it was stupid question:) Re: Test Valentin (PSU) 5 Oct 2011 11:36 Thanks for tests... If you have WA#23 usind C# remember that Math.Sqrt(-1) = NaN :) |
| WA#3!!!!!! | Nastya | 1656. Far Away Kingdom's Army | 18 Jul 2018 07:17 | 3 |
Help me please with the test number 3 try this test case: 5 170 170 180 175 170 175 175 170 175 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 170 1 1 1 170 175 170 1 1 175 180 175 170 1 1 175 1 1 1 1 1 1 1 |
| WA test#3 what is the problem?? | sj alim | 1025. Democracy in Danger | 16 Jul 2018 02:36 | 1 |
#include<stdio.h> int main() { int n,i,j,item[9999],a,sum=0,temp; scanf("%d",&n); for(i=0; i<n; i++) scanf("%d",&item[i]); for(j=1; j<n; j++) for(a=n-1; a>=j; a--) { if(item[a-1]>item[a]) { temp=item[a-1]; item[a-1]=item[a]; item[a]=temp; } } for(i=0; i<((n+1)/2); i++) { sum=sum+(item[a]+1)/2; } printf("%d\n",sum); return 0; } |
| Hint. | ag2cidk | 2034. Caravans | 14 Jul 2018 05:22 | 1 |
Hint. ag2cidk 14 Jul 2018 05:22 BinSearch. Edited by author 14.07.2018 05:22 |
| For those who WA5 | Aksima | 1039. Anniversary Party | 14 Jul 2018 02:16 | 1 |
Do not use signed char (C++) or signed byte (C#) to store convivality, or you get wrong results because of overflow. The test 5 is: 7 1 1 100 100 1 1 1 1 3 2 3 6 4 7 4 4 5 3 5 0 0 After you sum 100 + 100, you get -56 in the signed char/signed byte variable, while the right sum should be 200. Hope this helps. |
| WA 39 | Md sabbir Rahman | 1872. Spacious Office | 14 Jul 2018 00:50 | 1 |
WA 39 Md sabbir Rahman 14 Jul 2018 00:50 getting WA 39, can anyone please provide some test cases? |
| WA #11 Help me! | letranloc | 1416. Confidential | 13 Jul 2018 21:52 | 3 |
I got WA at #11. I had tested all tests on discussion and It's print right answer! Can anyone tell me some tricks? i don't know the mistake!!! What's #11??? The same to me :( Can the author of the problem show the test case or someone give more tests, please? Edited by author 13.07.2018 21:54 |
| Any hint ??? | xurshid_n | 2007. Mutants versus Machines | 13 Jul 2018 20:27 | 2 |
I'm WA15 always. My program passes all tests given there discussion, but can't AC. |