Общий форумHello, i am a newfag at this judge system, and i have some questions: The output information must be minimalize, or only no longer than 10000 symbols? Different and true solutions are all accepted? What biggest number 'n' could be? Edited by author 19.03.2010 03:26 IMHO just no longer than 10000 symbols. 3 ≤ n, m ≤ 8 Yes, any answer, not longer than 10000 symbols will be accepted. ikatanic judge [1] 3 апр 2010 13:27 hi, on the status page, what does Execution time shows exactly when I get WA? just that test case or that case and all cases before dAFTc0d3r [Yaroslavl SU] Re: judge 3 апр 2010 14:55 "that case and all cases before" It seems that it shows the MAX( t[i] ) Where t[i] is a time that program worked on test i, and 1 <= i <= WA_test - test, that you didn't pass. Of course! That's easy,and please look at the example,and then just simulate it,and then you'll get AC!! Good luck! Of course u are the best, u should do this, Good Luck! Nice trick. Check the ranklist. Who modified it this way? Allelui!! I am 171th with my 51 problems solved!! ^^ Yay, having screenshot with you as #1 on Timus is really nice =) haha! that's true ^^ Yea, 1st place its cool!:D I think, that today amount of accepted solutions was bigger, than usually. IMHO Many author's wants to see themselves at first line of ranklist :) I have made screen shot of web page with my "achievement" in memory of that nice day :) Edited by author 02.04.2010 02:00 Just write in your code: ... scanf("%d",&n); if (n == 0){ printf("0"); return 0; } ... When I write it I got AC Good Luck :-) Thank you, I got AC too :) I don't know whay this system returnes "wrong answer" !!! I ran my program several times,both in windows console and Netbeans IDE and every time i got the expected result. but here neither sending source file nor pasting source code doesnt accept ! and here is the code,if anyone interested : /* * this class implements the encoding requested in problem #1706 */ /** * @author Esmaeil Ashrafi <s.ashrafi@gmail.com> */ import java.util.ArrayList; public class StierlitzCipher { private static String input; // the string suppose to be ciphered private static int k; // the length of sub strings // temporary variable for query substrings private static StringBuffer temp = new StringBuffer(); // an array to store substrings of each query string private static ArrayList<String> sub = new ArrayList<String>(); /** * @param args the command line arguments */ public static void main(String[] args) { /* if ran in command line console,first argument willl be the * string to cipher and second considered as the key */ if (args.length == 2) { input = new String(args[1]); k = Integer.parseInt(args[0]); } // otherwise use of default values of problem else { input = new String("abaccc"); k = 3; // prompt the user to using default values System.out.println("doing encrypt by default values:" + "\nString : \"abaccc\"\nKey : 3"); } query(input, k); System.out.println(); // just for trimming the output ! }//end of main /** * gets the entire string and splits it to substrings in length * of "len" and sends each substring to method compute * for calculating the number of different non-empty substrings * could obtained from them.there will be substrings(and * consequent call to compute method)call as much as the length * of parameter str * @param str - the string to be cipher * @param len - the length of substrings(the key) */ private static void query(String str, int len) { int m, strLen = str.length(); for (m = 0; m <= strLen - len; m++) { compute(str.substring(m, m + len)); } for (m = m; m < strLen; m++) { compute(str.substring(m).concat(str.substring(0, len - (strLen - m)))); } }//end of query /** * queries queryString to calculate number of its different and * non-empty substrings and prints the count to the standard output * @param queryStr - the string to be queried */ private static void compute(String queryStr) { int qLen = queryStr.length(); for (int i = 0; i < qLen; i++) { for (int j = i + 1; j <= qLen; j++) { if (!sub.contains(temp.replace( 0, temp.length(), queryStr.substring(i, j)).toString())) { sub.add(temp.toString()); } } } System.out.print(" "+sub.size()); sub.clear(); }//end of compute }//end of class Edited by author 31.03.2010 05:29 1. Read FAQ. Programs should read and write data using standard input and output. You shouldn't use command line arguments to input data. 2. Don't output any debugging info and user prompt, like this: System.out.println("doing encrypt by default values:" + "\nString : \"abaccc\"\nKey : 3"); Thank you but there are more than 20 times i attempt to make my prog acceptable and EveryTime i got that "time limit exceeded". I have no idea after changing my code to the following (and this is just the last,i used any combination of String,StringBuffer you would think) how can make an acceptable answer while since the first time i ran my program i got the right answer ( but seems too late! ) And here is the last source code(the strategy is same as the first) : import java.io.*; public class StierlitzCipher2 { String input; // the string suppose to be ciphered int key; // the length of sub strings PrintWriter out ; StreamTokenizer in ; CharSequence temp ; public static void main(String[] args) throws IOException { new StierlitzCipher2().run(); } void run() throws IOException {
in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in.nextToken(); key = (int) in.nval; in.nextToken(); input = in.sval; out = new PrintWriter(new OutputStreamWriter(System.out)); query(input, key); out.flush(); }//end of run void query(String str, int len) { int m, strLen = str.length(); for (m = 0; m <= strLen - len; m++) { compute(str.subSequence(m, m + len)); } for (m = m; m < strLen; m++) { compute(str.substring(m).concat(str.substring(0, len - (strLen - m)))); } }//end of query void compute(CharSequence queryStr) { int qLen = queryStr.length(), subCounter = 0; CharSequence[] sub = new CharSequence[(qLen * (qLen + 1)) / 2];
for (int i = 0; i < qLen; i++) {
for (int j = i + 1; j <= qLen; j++) { breakPoint :{ temp = queryStr.subSequence(i, j); for (int k = 0; k < subCounter; k++) { // comparing the temp to elements of sub if (sub[k].equals(temp)) { subCounter--; break breakPoint ; } } sub[subCounter] = temp ;} ++subCounter; } } out.print(subCounter); out.print(" "); }//end of compute }//end of class Does anyone have any idea how to make it ? Shouldn,t i use String objects (nor CharSequence) and please dont talk about StringBuffer,i used that ... Thanks in advance Edited by author 01.04.2010 13:23 and here is the third version : package stierlitzCipher; // in this version i use String and String[] in method compute // instead of StringBuffer and Array<String> // and iteration in array "sub" is more more sufficent : // it doesn't itrate whole array,just compares the temporary substring // to elements with same length import java.io.*; public class StierlitzCipher3 { String input; // the string suppose to be ciphered int key; // the length of sub strings PrintWriter out; StreamTokenizer in; public static void main(String[] args) throws IOException { new StierlitzCipher3().run(); } void run() throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in.nextToken(); key = (int) in.nval; in.nextToken(); input = in.sval; out = new PrintWriter(new OutputStreamWriter(System.out)); query(input, key); out.flush(); }//end of run void query(String str, int len) { int m, strLen = str.length(); for (m = 0; m <= strLen - len; m++) { compute(str.substring(m, m + len)); } for (m = m; m < strLen; m++) { compute(str.substring(m).concat(str.substring(0, len - (strLen - m)))); } }//end of query void compute(String queryStr) { int subCounter = key, begin; String[] sub = new String[3*((key * (key + 1)) / 2)/2]; String temp; // initially inserting key subs as the least count for (int i = 1; i < key; i++) { sub[i-1] = (queryStr.substring(0, i)); } for (int i = 1; i < key; i++) { for (int j = i + 1; j <= key; j++) { temp = queryStr.substring(i, j); // comparing the temp to proper elements of sub begin = j - i-1 ; breakPoint: { do { if (temp.equals(sub[begin])) break breakPoint; } while (sub[(begin += key - 1)] != null); ++subCounter; sub[begin] = temp; } } } out.print(subCounter); out.print(" "); }//end of compute }//end of class /****************************************/ And(Again) the result is : time limit exceeded :( I don't know the problem is with algorithm i use or something about java i shoul consider... I think i should just leave it for the moment ! But i will be so thankful if anyboby guide me,cos i know there are submissions accepted programmed in java for this problem. This problem i walking on my nerve !!! Edited by author 01.04.2010 12:52 online judge with random statistics?))) solve any new problem and be the winner xD begin randomize; writeln(random(2)); end. Who can AC by this program??? =) if you are lucky enough Edited by author 31.03.2010 19:30 Edited by author 02.04.2010 18:03 Make a macro for "for" #define F(i,n) for(int i = 0; i < n; ++i) macros for start/process/stop of each line #define START int c0 = 0, ... #define P(x) if(x == 's'){ ... #define STOP mc0 = max(mc0, c0); ... vertical/horizontal lines are simple: F(i,n){ START; F(j,n) P(s[i][j]); STOP; } F(i,n){ START; F(j,n) P(s[j][i]); STOP; } The simplest diagonal is F(i,n) { START; F(j,i+1) P(s[ i-j ][ j ]); STOP; } with a macro for symmetry #define I(ind) n-1-(ind) the other lines simply invert some of coordinates: F(i,n) { START; F(j,i+1) P(s[I(i-j)][ j ]); STOP; } F(i,n-1){ START; F(j,i+1) P(s[ i-j ][I(j)]); STOP; } F(i,n-1){ START; F(j,i+1) P(s[I(i-j)][I(j)]); STOP; } задание: Формат каждого из этих списков таков: в первой строчке записано количество Ni чисел в i-м списке, далее в Ni строчках по одному числу в строке записаны сами списки. и тест не соответствует. если по заданию - то будет ответ НЕТ. т к надо брать следующие 4 строки. "Исходные данные: Состоят из двух (!) списков — одного, потом другого. Формат каждого (!) из этих списков таков: в первой строчке записано количество Ni (!) чисел в i-м (!) списке, далее в Ni строчках по одному числу в строке записаны сами списки." "Input: You are given both of these lists one by one. Format of each of these lists is as follows: in the first line of the list the quantity of numbers Ni of the i-th list is written. Further there is an i-th list of numbers each number in its line (Ni lines)." Just try to think a little bit more and you ACeed it. =) Can any one help me? I got WA#4. But I have no idea where I made a mistake. I need some tests. I might ignored something important. Thanks. Test: 0 + 0 + 2 . 1 ------ Answer: 1 2 + I think you assumed that it starts working from time = 1 s. :) I've checked this case and still get WA at 4. Here is the 4th test : Input : 0 . 16 1 . 10 27 . 35 74 . 22 79 + 107 . 8 147 + 185 + 232 . 21 279 + 325 + 347 + 380 + 407 + 412 . 6 445 . 24 473 . 43 486 . 21 520 . 26 552 + 552 + 565 . 19 583 + 613 . 8 653 . 16 673 . 20 675 . 49 675 . 3 678 . 48 695 . 9 704 . 12 741 + 786 + 809 + 810 . 22 834 + 846 . 35 878 + 921 . 27 946 + 984 . 10 995 . 28 1001 + 1002 + 1012 + 1043 + 1079 + 1107 . 16 1150 + 1180 + 1229 + 1265 + 1279 + 1293 + 1317 . 27 1336 + 1355 + 1361 . 16 1406 + 1438 + 1470 + 1506 + 1527 + 1545 + 1545 + 1567 . 27 1591 + 1626 + 1665 . 2000 1706 + 1755 . 17 1801 + 1829 + 1840 . 44 1843 + 1873 . 42 1909 + 1955 . 14 1989 . 17 2026 + 2072 . 20 2117 . 16 2161 . 7 2177 . 31 2224 . 5 2272 . 10 2276 + 2319 + 2332 + 2376 + 2380 + 2421 + 2457 + 2484 + 2533 . 18 2569 . 34 2585 . 18 2597 + 2598 + 2598 . 12 Correct output : - - - - 1 - 2 3 - 4 5 6 7 8 + - - - - 9 10 - 11 + - - - + - + - 1 2 12 - 13 - 14 - 4 + - 5 7 6 15 16 + 17 18 8 11 3 19 - 9 1 + 2 12 13 14 20 21 22 - 4 5 - 6 - 7 8 - 10 - 3 + - 1 + - + - + + 2 4 6 9 11 12 8 13 - - - 3 14 + Good luck . my soln is exactly equal to what u have posted. but failing in test 2. any reason?? please help Edited by author 05.04.2010 05:23 #include <iostream> #include <math.h> using namespace std; const double pi=3.1415926535897932; int main() { int a; int n; double r; double *x,*y; x=new double; y=new double; double P=0; cin>>n; cin>>r; for(a=0;a<n;a++) { cin>>x[a]; cin>>y[a]; } for(a=0;a<n;a++) { P+=sqrt((x[a+1]-x[a])*(x[a+1]-x[a])+(y[a+1]-y[a])*(y[a+1]-y[a])); } P+=pi*r*(n-2); P=double(int(P*100))/100; cout<<P; return 0; } это код Помогите Плиз PI лучше писать как pi = 2.0*acos(0.0) а формула же 2*Pi*r Edited by author 30.03.2010 22:31 #include <iostream> using namespace std; int main() { int n; cin >> n; //if(n==1) { cout << 0 << endl; return 0; } unsigned long long p,s=0; for(int i=2;i<=n;i++) { p=1; for(int j=n;j>=n-i+1;j--) p*=j; s+=p; cout << p << " "; } cout << endl; cout << s << endl; //system("Pause"); return 0; } Edited by author 30.08.2008 20:06 Edited by author 30.08.2008 20:08 test 13 is n=21 test 13 is 21 the correct answer is 4131306270 N = 21 ANS = 138879579704209680000 =) I got AC by brute forcing coordinates. Now I want to know a "real" solution for this one! Please someone contact me at ile-ngcmlfs@mail.ru Edited by author 01.04.2010 05:20 Hello! My submit has status "problem locked". What does it mean? This problem is under investigation. When it will be unlocked, your submits will be checked automatically. I wrote two idental programs in C++ and Pascal. First works for 0.565 sec, another for 0.062. I means, that tests for C++ and Pascal are different?! But why time is different??? If you used cin and cout ... I used cin/cout and still AC 0.046 |
|