Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Ford-Fulkerson tl22 | airibo | 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) | | 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 Re: Test Erofeev Artem 11 Nov 2010 00:47 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 ? Re: Test Erofeev Artem 11 Nov 2010 01:03 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:) 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. | pivasik | 2034. Caravans | 14 Jul 2018 05:22 | 1 | Hint. pivasik 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 ??? | coder | 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. | | WA#18 | joaopfg | 1422. Fireflies | 13 Jul 2018 12:18 | 1 | WA#18 joaopfg 13 Jul 2018 12:18 Someone can give some test case to help with WA18, please? Code: #include <bits/stdc++.h> using namespace std; #define MAXN 2010 #define INF -1 typedef long long int lli; typedef pair<lli,lli> ii; typedef pair<ii,ii> pp; lli gcd(lli a,lli b){ if(a<0) a=-a; if(b<0) b=-b; if(b==0) return a; else return(gcd(b,a%b)); } int maxPoint = 1,curMax, overlapPoints, xLine, yLine, zLine; map<pp,int> slopeMap; int main(){ int n; //int x[MAXN],y[MAXN],z[MAXN]; lli x[MAXN],y[MAXN],z[MAXN]; scanf("%d",&n); //for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&x[i],&y[i],&z[i]); if(n==1) printf("%d\n",maxPoint); else{ maxPoint = 0; for(int i=1;i<n;i++){ curMax = overlapPoints = xLine = yLine = zLine = 0; for(int j=i+1;j<=n;j++){ //int xDif = x[j] - x[i]; //int yDif = y[j] - y[i]; //int zDif = z[j] - z[i]; lli xDif = x[j] - x[i]; lli yDif = y[j] - y[i]; lli zDif = z[j] - z[i]; if(xDif == 0 && yDif == 0 && zDif == 0) overlapPoints++; else if(xDif == 0 && yDif == 0) zLine++; else if(xDif == 0 && zDif == 0) yLine++; else if(yDif == 0 && zDif == 0) xLine++; else if(xDif == 0){ //int num1 = abs(yDif); //int den1 = abs(zDif); //int yz = gcd(num1,den1); lli num1 = abs(yDif); lli den1 = abs(zDif); lli yz = gcd(num1,den1); num1 /= yz; den1 /= yz; if((yDif > 0 && zDif > 0) || (yDif < 0 && zDif < 0)){ slopeMap[make_pair(make_pair(num1,den1),make_pair(0,0))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(num1,den1),make_pair(0,0))]); } else{ slopeMap[make_pair(make_pair(-num1,den1),make_pair(0,0))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(-num1,den1),make_pair(0,0))]); } } else if(yDif == 0){ //int num1 = abs(xDif); //int den1 = abs(zDif); //int xz = gcd(num1,den1); lli num1 = abs(xDif); lli den1 = abs(zDif); lli xz = gcd(num1,den1); num1 /= xz; den1 /= xz; if((xDif > 0 && zDif > 0) || (xDif < 0 && zDif < 0)){ slopeMap[make_pair(make_pair(num1,den1),make_pair(INF,INF))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(num1,den1),make_pair(INF,INF))]); } else{ slopeMap[make_pair(make_pair(-num1,den1),make_pair(INF,INF))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(-num1,den1),make_pair(INF,INF))]); } } else if(zDif == 0){ //int num1 = abs(xDif); //int den1 = abs(yDif); //int xy = gcd(num1,den1); lli num1 = abs(xDif); lli den1 = abs(yDif); lli xy = gcd(num1,den1); num1 /= xy; den1 /= xy; if((xDif > 0 && yDif > 0) || (xDif < 0 && yDif < 0)){ slopeMap[make_pair(make_pair(INF,INF),make_pair(num1,den1))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(INF,INF),make_pair(num1,den1))]); } else{ slopeMap[make_pair(make_pair(INF,INF),make_pair(-num1,den1))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(INF,INF),make_pair(-num1,den1))]); } } else{ lli num1 = xDif*xDif + yDif*yDif; lli den1 = zDif*zDif; //int num2 = abs(xDif); //int den2 = abs(yDif); lli num2 = abs(xDif); lli den2 = abs(yDif); lli gcd1 = gcd(num1,den1); lli gcd2 = gcd(num2,den2); //int gcd2 = gcd(num2,den2); num1 /= gcd1; den1 /= gcd1; num2 /= gcd2; den2 /= gcd2; if((xDif < 0 && yDif > 0 && zDif > 0) || (xDif > 0 && yDif < 0 && zDif > 0)){ slopeMap[make_pair(make_pair(num1,den1),make_pair(num2,den2))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(num1,den1),make_pair(num2,den2))]); } else if((xDif < 0 && yDif < 0 && zDif < 0) || (xDif > 0 && yDif > 0 && zDif < 0)){ slopeMap[make_pair(make_pair(-num1,den1),make_pair(-num2,den2))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(-num1,den1),make_pair(-num2,den2))]); } else if((xDif < 0 && yDif < 0 && zDif > 0) || (xDif > 0 && yDif > 0 && zDif > 0)){ slopeMap[make_pair(make_pair(num1,den1),make_pair(-num2,den2))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(num1,den1),make_pair(-num2,den2))]); } else if((xDif < 0 && yDif > 0 && zDif < 0) || (xDif > 0 && yDif < 0 && zDif < 0)){ slopeMap[make_pair(make_pair(-num1,den1),make_pair(num2,den2))]++; curMax = max(curMax,slopeMap[make_pair(make_pair(-num1,den1),make_pair(num2,den2))]); } } curMax = max(curMax,xLine); curMax = max(curMax,yLine); curMax = max(curMax,zLine); } maxPoint = max(maxPoint,curMax + overlapPoints + 1); slopeMap.clear(); } printf("%d\n",maxPoint); } return 0; } Edited by author 13.07.2018 15:13 | | WA6 | Md sabbir Rahman | 1422. Fireflies | 12 Jul 2018 09:00 | 1 | WA6 Md sabbir Rahman 12 Jul 2018 09:00 I am getting WA at 6 using floating arithmatic. Can someone please provide any test for test # 6? | | Ellipsoidal cap | Gilles Deleuze | 1562. GM-pineapple | 11 Jul 2018 19:54 | 1 | Search for "Ellipsoidal cap volume" on the internet if you got stuck with this problem. You can find derivation of a formula needed for this problem. | | What is Test Case 2? | A.M. | 1196. History Exam | 11 Jul 2018 08:41 | 1 | I submitted my solution, but it says Test Case 2 didn't pass. Could anyone tell me what the test case is? | | Hint | Gilles Deleuze | 1145. Rope in the Labyrinth | 11 Jul 2018 00:19 | 1 | Hint Gilles Deleuze 11 Jul 2018 00:19 The problem asks you to find the diameter of a tree. | | wa3 | Fyodor Menshikov | 1741. Communication Fiend | 10 Jul 2018 23:04 | 2 | wa3 Fyodor Menshikov 2 Nov 2009 21:44 If you have wa3 the following test may help you: 3 4 1 2 10 Pirated 1 2 11 Licensed 2 3 10 Pirated 2 3 8 Licensed answer Online 19 Re: wa3 Adarsh Kumar 10 Jul 2018 23:04 cracked can be installed on both licensed and pirated and the program remains licensed or pirated as before installation I overlooked this case and got wa3 P.S. above test case didn't help |
|
|