Common Boardall the tires are of the same size and not different telling coz got an ac Edited by author 18.02.2012 07:18 And there are can be more than 4 tires the same size. Good luck! Edited by author 05.04.2010 05:23 #include <iostream> #include <string.h> using namespace std; void main() { int exp = 0; char fast[10]; int optimal = 0; int no_optimal = 0; int gorih; cin >> exp; for(int i = 1; i <= exp; i++) { cin >> gorih; cin>>fast; if(!strcmp(fast,"satisfied")) { if(optimal > gorih) { optimal = gorih;}if(optimal == 0){optimal=gorih;}} else {if(no_optimal==0){no_optimal=gorih;}if(no_optimal<gorih){no_optimal=gorih;}} } if(optimal == 0){cout<<"Inconsistent";} else if(optimal>no_optimal){ cout<<optimal;} else {cout<<"Inconsistent";} } It is known as a fact, that ten walnuts is always enough and two walnuts are always not enough. Add this test, please 45 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 0 0 0 9 Good answer 0 But some greedy algorythms answer 1 P.S. Sorry for my english( my algo wrote 9 :D :D :D thanks heped me i think test 7 is like that а где вы видели купюры достоинством 0 (рублей, долларов, евро, фунтов, франков...) ??? ;) "В следующих N строках даны достоинства K этих банкнот (0 <= K <= 10^9)." Is there any possible way to solve it without long arithmetics in C++? please, if yes, tell me what types should i use. Thanks. Maybe double and rounding will help? But I solved using C# and BigInteger. Please! Give me 10 test Try this: 2 1 1 3 1 2 3 2 5 15 The answer must be 0! "In the second line you are given n distinct integers in ascending order.." DISTINCT! Why in your test you have "1 1" numbers? ??? 4 3 1 5 5 I have answer 1. But WA6...... Edited by author 08.08.2011 22:55 Why 1?? maybe -1? 1-4=> -3-4+5=> -2-4+5 => -1 There is couldn't be a negative number of cars at the crossroad.Either the cars does not exist or they are. Good luck! The answer should be 2 in that case... 4-1 => 0 4-5 => 1 4-(5+1) => 2 The answer is 2 1) To get current count of cars in traffic jam, you have to add count of city-cars and previous jam-cars and substract cpm-value (car per minute). 2) Don't forget to set to zero jam-cars, if jam-cars value less than zero, because, in that case, there is no cars on crossroad in that moment! Good Luck! Maybe this one will help you: 1 1 1 0 (x)(x+1)(x2+1) It didn't help me. Can anyone say about other test case? Please explain the sample input output. God I am fed up. Please tell me what is access violation It's when your program tries to access memory address that doesn't belong to it. In C++, use STL vector instead of arrays. It solved the problem, in my case :) My algo is O(n * sqrt(n)) But i have WA on test 18. My solution gives same answers with brute force solution on my random tests. But what is 18-th test? Can anybody help me? Maybe, arithmetic overflow? Some answers may not fit in the standard 32-bit integer types... Really? Yes, I use usual int instead __int64. But in problem statement Q <= 10^5 and V <= 10^4 for all I queryes. So all values on nodes is <= 10^5*10^4. It is less than 2^31-1. But... maybe I misuderstud anything? BTW I will try submit with __int64 :) Thank You! Any more ideas? It fits in 32 bit integers. (I got AC using long). I also used O(n * sqrt(n)) (teoretically) but I can't think why you get WA on test 18... there must be a mistake someware. AC now! here it is program that generated contrary test for my solution: n = 10000; printf( "%d\n", n ); for (i = 0; i < n-1; ++i) { printf( "%d %d\n", random(i+1)+1, i+2 ); } m = 1000; printf( "\n%d\n", m ); k = random(m); for ( i = 0 ; i < k ; i++ ) printf( "I %d %d\n", random(n) + 1, random(10001) ); for ( i++ ; i < m ; i++ ) printf( "G %d %d\n", random(n) + 1, random(n) + 1 ); How can solve this problem in O(N * sqrt(N)) ?? Is it simple to implement ? My solution is O(N * log^2(N)). But it's very complex and slow ( 4.25s ) my program work about N*sqrt(N) but i have TL 17 any ideas about this test? why we have to use __int64? Can U tell me about ur method this is my email oybek_all@yahoo.com Edited by author 03.08.2008 14:40 help me, please!! How solved? What algorithm? Tried through LCA and RSQ but could not....mail: Vashegin_roman@mail.ru Build clusters of O(sqrt(N)) in size using DFS-inside-DFS. Outer clusters tree will have O(sqrt(N)) diameter. Optimize by skipping a cluster completely when you find a way. When you increase radiation level, enumerate all "downward portals" to other clusters passing through incremented node, and update their skip-values (maximal radiation level on the path from downward portal towards upward portal to parent cluster). Keep separate list of in-cluster edges. Although outer cluster tree's diameter is O(sqrt(N)), its size is still O(N) (there can be a lot of tiny leaf clusters). You don't want to enumerate all of them if you want to stay at O(sqrt(N)) during increments :) Edited by author 09.09.2008 02:44 More simply: Divide Tree in sqrt(N) layers and in clusters. If cluster small jumping through layer when forming answer on 'G' query, but renewing for verteces of this cluster information on each 'I' query. If cluster big go through it by step by step but in this case renewing information only for one vertex in 'I' query. No needed now. Edited by author 06.06.2012 15:50 Please help me!!! I can't pass 12 test. I tried all possible test's: with one senators, with not coherent senators, with all coherents senators and many-many others...In my computer always work, but not on this site. Maybe someone can say me what is the 12 test? Try this test, may it'll help you 7 2 7 0 3 0 4 0 5 0 3 0 1 0 6 0 try this test: 9 3 5 0 3 0 2 8 0 5 0 4 6 0 7 9 0 6 0 9 0 0
Ну как? My program passed all these tests but still have WA12 :( #include <iostream> #include <cstdio> #include <cstdlib> #include <math.h> #include <iomanip> using namespace std; int main() { setlocale (LC_ALL, "Russian"); int N; double R; const double PI = acos(-1.0); cin >> N >> R; if((N < 1) || (N > 100)) exit(0); if(R<=0) exit(0);
double a[101][2];
for(int i = 0; i < N; i++) { for(int j = 0; j < 2; j++) { cin >> a[i][j]; } } a[N][0] = a[0][0]; a[N][1] = a[0][1]; a[N+1][0] = a[1][0]; a[N+1][1] = a[0][1]; a[N+2][0] = a[2][0]; a[N+2][1] = a[2][1];
double dLength = 0.0, dSide1, dSide2, dSide3, dCurve, alpha; for(int i = 0; i < N; i++) { dSide1 = 0.0; dSide2 = 0.0; dSide3 = 0.0; dCurve = 0.0; for(int j = 0; j < 2; j++) { dSide1 += (a[i][j] - a[i+1][j])*(a[i][j] - a[i+1][j]); dSide2 += (a[i+1][j] - a[i+2][j])*(a[i+1][j] - a[i+2][j]); dSide3 += (a[i][j] - a[i+2][j])*(a[i][j] - a[i+2][j]); } dSide1 = sqrt(dSide1); dSide2 = sqrt(dSide2); dSide3 = sqrt(dSide3); alpha = (dSide3*dSide3 - (dSide1*dSide1 + dSide2*dSide2)) / (-2*dSide1*dSide2); alpha = PI / 2 - alpha; alpha = alpha * 180/PI; dCurve = 2 * PI * R * (180 - alpha) / 360; dLength += dSide1 + dCurve; }
if (N == 1) dLength = 2 * PI * R; if (N == 2) dLength = 2 * PI * R + 2 * dSide1;
cout << setprecision(2) << setiosflags (ios::showpoint | ios::fixed) << dLength; return 0; } I also had WA 19. There are some tricks to get AC in Java using java.util.Date. Take your tambourine and let's go! 1. Divide milliseconds count by 24*60*60*1000. 2. January's index is 0, not 1. 3. Use, for example, year-1500 instead of year. 4. Use Date's deprecated constructor. You don't have to care about all those details. Use GregorianCalendar it will take care everything for you. The tests are a little bit incorrect. If we have, let's say, 10 boxes of the first variety and 10 boxes of the second variety we can come up with: 1 2 3 4 5 6 7 8 9 10 10 20 30 40 50 60 70 80 90 100 (1 line: from 1 to n; 2 line: from n to m*n with step of n) In this case we never allocate boxes of even weight. If we take box number 10 from the first line and box number 3 from the second, we get 10+30=40. The best solution would be the box number 1 from the first line and the box number 4 from the second one: 1+40=41. But 40!=41 The system gives me WA on the very first test. All integers in output must be different, so your answer is wrong. Oops... Indeed! Shame on my inattention :( Thanks, mate! please help me,i have got a wrong at #14,but i can't think out where is wrong,please give me some test if you get WA 7 be careful! This code get WA: mypow(sum1,4) - 6*sum2*sum1*sum1) + 8*sum3*sum1 + 3*sum2*sum2 - 6*sum4 But this code get AC: mypow(sum1,4) %p - (6*(sum2*sum1%p)*sum1) %p + 8*(sum3*sum1%p) %p + 3*sum2*sum2 %p - 6*sum4 %p =) Who can tell me , how to solve this problem with Dynamic programming? Ac!! after some correction! Hint: passed time and waited time need to corrected (i.e. change to real values) Write your e-mail. I help you. |
|