|
|
Common BoardI have a problem with test5!.Wrong anwser!!! Can anyone help me?. What is the test 5? I have solved this problem!!!. I am stupid!. I have solved this problem!!!. I am stupid!. minimal amount of money necessary for the optimization of the existing flight scheme is long long type. Edited by author 16.11.2012 12:38The project is not very difficult. The test is so easy. ^^ Thanks for the help...i spent a day debug my code :) for each node v,calculate a(v)-maximum cost achieved by the subtree with root "v" in which v will attend, and n(v)-maximum cost achived by the subtree with root "v" in which v will not attend. a(v)=p(v)+n(v1)+n(v2)+...+n(vn), vi-is the child of v.,p(v)-is the point of v itself. n(v)=sum(max(n(vi),a(vi))),for all i-s. and simply use DFS. This is my program: [code deleted] Be careful of the s and t.In TEST#8,s>t. Edited by moderator 23.10.2019 08:45 Thanks a lot That last line you wrote got me through :) * New tests have been added. * First test is now the sample from the problem statements. * Memory limit is changed from 16 MB to 64 MB. * Time limit is changed from 2 seconds to 1 second. Solutions have been rejudged. More than 1700 authors have lost AC. I create a struct STACK like this: struct STACK { int number; unsigned char before[3]; }; and keep arrays: STACK LIST[100000+1]; int last[1000]; Apparently (3B+4B)*10^5 = 7*10^2 KB which is less than 750 :D whats wrong with it? :/ how much memory does an empty cpp code consume? UPD: now I use these arrays and structs: struct STACK { int number; unsigned short before; }; int last[1000]; int counter = 0; STACK *LIST = new STACK[100000+1]; int tmp = -1; string strr("PUSH"); int additional_bit[3200]; char STR[5]; and still MLE XDXD btw, an empty cpp code uses ~80KB which is OK for my code but why does it still fail?:/ I think your struct is packed by compiler into nearest div 4 byte blocks, i.e. into 8byte blocks. Try to use arrays instead or search for additional compiler options What the ***? Edited by author 28.03.2013 22:52 finally... omg, the tests are really hard. Edited by author 28.03.2013 07:06 Finally AC, Edited by author 28.03.2013 07:06 Hi, Does the solution require the set having the minimum cardinality having numbers that sums to k*n? I am getting a WA, but the solution appears pretty right to me. If so, the question makes it appear that you can get by with any set. @Mods can this be updated in that case? Thanks. Does it say it requires a minimum cardinality? can any explain the test case in the problem ,how the answer comes out to 383. Thanks in advance 100 + 2 * sqrt(2) * 100 sqrt(2) * 100 is the length of the diagonal of the square with side = 100 For those who are stuck at this point. The filtered (thus 0x0a and 0x0d removed) first testcase is: "a ?" (w/o quotes) #include<stdio.h> #include<stdlib.h> int main() { long unsigned int a[15000][2],i,j,n,temp,b,c; scanf("%ld",&n); for(i=0;i<n;i++) { scanf("%lu%lu",&b,&c); if(b<=10000000&&c<=100) { a[i][0]=b; a[i][1]=c; } else { return 0; } } for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { if(a[j][1]<a[j+1][1]) { temp=a[j][0]; a[j][0]=a[j+1][0]; a[j+1][0]=temp; temp=a[j][1]; a[j][1]=a[j+1][1]; a[j+1][1]=temp; } } } for(i=0;i<n;i++) { for(j=0;j<2;j++) { printf("%d ",a[i][j]); } printf("\n"); } return 0; } Edited by author 27.03.2013 18:08 You can try with 2 2 3 The output should look like this 2 1 2 1 2 her's my cod! Please help! using System; namespace ConsoleApplication1 { class Program1563 { static void Main() { int n = int.Parse(Console.ReadLine()); string str; string[] strl = new string[n]; int s = -1; for (int i = 0; i < n; i++) { str = Console.ReadLine(); strl[i] = str; Console.WriteLine("i="+i); for (int j = 0; j < i; j++) { if (str == strl[j]) s++; } }
Console.WriteLine(s); Console.ReadLine(); } } }
When you compare in the sort, try using epsilon = 1e-8. When I used 1e-13, I keep getting WA#3. I didn't understand that squares could be rotated. My solution works with both EPS = 1e-7 and 1e-14. Edited by author 26.03.2013 23:59 I use O(n^3), but i meet time problem. Can you help me? Of course, the best complexity is O(N^2 log N), but O(N^3) can get AC. Can anybody in short explain how to create O(N^2 logN) algorithm, please? I've already accepted O(n^3) solution and there's no promlem with it(definitely not the best implementation of this algorithm got ac in 0.2 sec), but how to create O(N*NlogN) algo? Use angle sort, after use binary search. I've Accepted O(N*NlogN) :) N^2 * log(N^2) algo: 1) Sort n^2 lines by distance. 2) Iterate from largest to smallest. 3) We have to add line to the answer, if we not have bigger line in set, covering this. We can easily check it with set. O(N^3) easily gets AC in 0.078s. #include <iostream> int ClickCount(char c); using namespace std; int main() { char Buf[1001]; cin.getline(Buf,1001); int Result=0; int i=0; while (Buf[i]!='\0') { Result+=ClickCount(Buf[i]); i++; } cout << Result; //system("pause");
return 0; } int ClickCount(char c) { char AlphaBet[]="abcdefghijklmnopqrstuvwxyz*.,!# *"; for (int i=0;i<=sizeof AlphaBet;i++) { if (c==AlphaBet[i]) return i%3+1; } return 0; } It took me 2 minutes to finish it. This problem is similar to the 1496. I changed several lines of code and ACed it from first attempt. The frase "There are no brands, that differ only in register" suggests that the "Mexx" and "MEXX" is the same brand, but in fact this condition just does not make sense. I agree, this problem wasn't really a problem if N=3 k=10 is 011 valid(i mean may the valid number start with 0?) 011 is actually 11 so no. a small hint: first, lets consider A ∈ { 1, 2, 3, ..., k-1} the numbers that are invalid should look like this: A00, where A can take any value from those above. no matter what values do N and K take, your numbers must always start with A. if not, then u have a number with N-1 elements. hope this helps. this reply was quite late :-) Edited by author 26.03.2013 14:03 import java.util.*; public class LavinInteractive {
public static void main(String[] args) { int n; Scanner rc = new Scanner(System.in); System.out.print("Введите число: "); n = rc.nextInt();
if (( n >= 1 ) && (n <= 4)) { System.out.print("few"); } else if (( n >=5 ) && (n <= 9)) { System.out.print("several"); } else if (( n >= 10 ) && (n <= 19)) { System.out.print("pack"); } else if (( n >= 20 ) && (n <= 49)) { System.out.print("lots"); } else if (( n >= 50 ) && (n <= 99)) { System.out.print("horde"); } else if (( n >= 100 ) && (n <= 249)) { System.out.print("throng"); } else if (( n >= 250 ) && (n <= 499)) { System.out.print("swarm"); } else if (( n >= 500 ) && (n <= 999)) { System.out.print("zounds"); } else if ( n >= 1000 ) { System.out.print("legion"); }
} } System.out.print("Введите число: "); =) quess reason |
|
|