| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Спасибо за задачу | nobik | 1203. Научная конференция | 17 янв 2015 15:35 | 2 |
Thanks for the site problem, a very interesting and exciting)) Passed with PD + Segment tree. Edited by author 16.06.2012 05:41 Edited by author 16.06.2012 05:42 Yes, thanks for the problem. My solution is one sort, DP without recursion and with binary search. AC since 19th try :) |
| Compiler time differences | Tural Neymanov | 1613. Для любителей статистики | 17 янв 2015 15:07 | 1 |
So my algo is to have a vector of pairs(value and index), sort them(used usual <algorithm> sort), and then binary searched each request - first by value, and if value was correct, by index. The program ACed, on G++11 compiler with 0.921 time. when I removed the inclusion of <cstdlib>, it ACed with 0.859(and same on G++14). But funny thing is, on Visual C++ 2010, it ACed with 0.593s time, which is astounding(to me at least) because the difference is quite noticeable(25% drop). So I guess if you are getting TLE, it's worth a try to run it with Visual C++ - you might get a pass this way. Edited by author 17.01.2015 15:10 |
| Please add tests | Orfest (Novosibirsk SU) | 2032. Теория заговора и ребрендинг | 17 янв 2015 03:09 | 1 |
My Accepted solution #6069000 will fail if you add all permutations of test 32 as separate tests. |
| [C#] Looks right but it's wrong | Rensaku | 1001. Обратный корень | 16 янв 2015 21:23 | 3 |
Can any one see what's the issue? static void Main(string[] args) { string input = Console.In.ReadToEnd(); var valid = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; var sb = new StringBuilder(); var numbers = new Stack<string>(); for (int i = 0; i < input.Length; i++ ) { if(valid.Contains(input[i])) { sb.Append(input[i]); } else if(sb.Length > 0) { numbers.Push(sb.ToString()); sb.Clear(); } } NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo; foreach(var n in numbers) { double sqrt = Math.Sqrt(double.Parse(n, nfi)); Console.WriteLine(string.Format(nfi, "{0:F4}", sqrt)); } } . Edited by author 16.01.2015 20:50 If the input stream ends with a digit, your code will lose it. For debugging - replace Console.In.ReadToEnd with Console.ReadLine and try to read string with one symbol "1" |
| Time limit | Snowball_TverSU | 2030. Защитная Бэкап-Система | 15 янв 2015 16:33 | 6 |
Hello everyone. I always receive time limit on Test №21. Could you give any hints? Maybe this task requires special data structure (I try to represent tree as list of edges or adjacency list) or there is interesting algorythm? Thanks for reading. Not update connected vertexes for vertexes with amount of connections more than Sqrt(N). In this case sum for vertex will be current sum + delta for connected vertexes with size more than Sqrt(N). I have the same problem with TLE #21 and I can't understand your hint: what's that 'delta', how can I track/calculate it? I realize that the bottleneck is in vertices with high amount of linked edges but I can't understand how to avoid them - I still need update all vertices, otherwise I loose data for next steps. yes, you're right about data structure. I used binary indexed tree to solve the problem. Overall complexity is O(n + m * logn). So, you actually preprocess data in O(n) time and for each query you spent O(logn) time, which perfectly fits time constraints of the problem |
| Changes in problem 1500 Pass Licenses | Vladimir Yakovlev (USU) | 1500. Разрешения на проезд | 15 янв 2015 16:16 | 3 |
* Clarification in problem statements: For any pair of crossroads no two segments of the same category connect these crossroads. * Tests not satisfing this condition are corrected. * The first test is changed to the sample from the problem statements. * New time limit is 2.5 seconds (old time limit was 3 seconds). * New memory limit is 64 MB (old memory limit was 16 MB). * New tests are added All solutions are rejudged. More than 100 authors lost AC during this rejudge. * Clarification in problem statements: For any pair of crossroads no two segments of the same category connect these crossroads. Sample test 0 2 0 0 2 1 is this true? * Clarification in problem statements: For any pair of crossroads no two segments of the same category connect these crossroads. Sample test 0 2 0 0 2 1 is this true? Yes, of course! |
| Test 10 | Ignat Zakrevsky | 1490. Огненный круг | 15 янв 2015 16:10 | 2 |
Test 10 Ignat Zakrevsky 13 фев 2007 21:21 Give me some test. Or give me test 10! Edited by author 14.02.2007 18:59 |
| How to read input in Java? | Maigo Akisame (maigoakisame@yahoo.com.cn) | 1033. Лабиринт | 15 янв 2015 15:52 | 5 |
Is there a class or sth that can both read integers and single chars? Somebody please give me some example code. Thanks! I write this: import java.io.*; public class Main { static BufferedReader in; //........ public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(in.readLine()); //..... for(int i=1; i<n+1; i++){ for(int j=1; j<n+1; j++) { lab[i][j] = (char)in.read(); while(lab[i][j]!='#' && lab[i][j]!='.') lab[i][j] = (char)in.read(); //in win used two bytes end of line, in *NIX 1 byte } in.read(); } //..... import java.util.*; import java.io.*; public class Main{ public static void main(String[] argv) throws IOException{ new Main().run(); } PrintWriter pw; Scanner sc;
public void run() throws IOException{ boolean oj = System.getProperty("ONLINE_JUDGE") != null; Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt"); Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt"); sc = new Scanner(reader); pw = new PrintWriter(writer); int n = sc.nextInt(); int arr[][] = new int[n+2][n+2]; for(int i=1;i<=n;i++){ String str = sc.next(); for(int j=0;j<n;j++) if(str.charAt(j)=='.') arr[i][j+1] = 1; } //... pw.close(); }
} The best template for Java: BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer tok = null; String readToken() throws IOException { // reads the token; to read a full line use in.readLine() while (tok == null || !tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); } return tok.nextToken(); // sometimes it's better to use nextToken(String) method here } int readInt() throws IOException { // write readDouble(), readLong(), readBigInteger() methods if necessary return Integer.parseInt(readToken()); } In addition to previouse answer char[] arr = readString().toCharArray(); //reads string and creates an array of characters. It works not so fast, but for small input, like this, it would be the quickest way to write a code. If you want to read for 1 char manual try this: char readChar() throws IOException{ int x = 0; while ((x = in.read()) == '\n' || x == '\r' || x == ' '){ } return (char)x; } |
| Test case 5 | Arinjay Patni | 1725. Аншлаг, аншлаг! | 15 янв 2015 03:05 | 1 |
Please help me .this code failed at test case 5 #include <stdio.h> int main() { int n,k; scanf ("%d\n%d" ,&n,&k); int l, pos; l = n % 2 ;
if ( l != 0 || n < 1 || k < 1 || k > n || n > 50 ) { printf("invalid input"); } else { if (n != 2 ) { if ( k <= n/2 ) { pos = n/2 - k ; printf("%d", pos); } else { pos = k - ((n/2) + 1 ); printf("%d", pos); } } } if ( n == 2 ) { pos = 0; printf("%d", pos); } return 0; }
|
| Time limit exceeded | Lincoln | 1247. Проверка последовательности | 14 янв 2015 23:00 | 3 |
used: ... for(i=1;i<=S;i++) for(j=i;j<=S;j++) ... But the result is 'Time limit exceeded'. Please help, why 'Time limit exceeded'? don't use brute force... O(n^2) n=30000 ===>>> time limit) hint: you can don't use N in your solution brute force (with some optimizations) works fine |
| Test case 11 | aybek | 1018. Двоичная яблоня | 14 янв 2015 19:46 | 2 |
Hi, guys! Can't move throw #11 test. Need help. I just have build tree, and in every step removing smallest leaf. At last, I count sum of left leaf's weight and print it. But, algorithm don't pass at #11 test. Thanks 7 3 1 2 12 1 3 1 2 4 30 2 5 30 3 6 30 3 7 30 Correct answer is 72, your answer 61 |
| test 3 and answer | Aleqsandre Skhirtladze | 1068. Сумма | 14 янв 2015 14:25 | 1 |
what is test #3; 3 or what? don't you think that when n>0 answer is (n*(n+1))/2? when n<0 answer is (-((n*(n-1))/2-1))? when n=0 or n=1 answer is 1 ? Edited by author 14.01.2015 14:52 |
| a confusing statement | yongwhan | 2024. Время приключений | 14 янв 2015 05:20 | 1 |
please change the wording of the statement: "there should be at most k Rocks of pairwise different colors among the Rocks taken from the Cave" would be much better read if it is changed to "there should be at most k Rocks of different colors among the Rocks taken from the Cave." in other words, the word 'pairwise' should be removed to make the statement clear. Edited by author 14.01.2015 05:20 Edited by author 14.01.2015 05:21 |
| Ideas | Artem Khizha [DNU] | 1824. Ифрит-бомбардировки | 13 янв 2015 19:10 | 10 |
Ideas Artem Khizha [DNU] 19 мар 2011 18:26 I tried greedy approach during the contest, but got failed. Idea was in bombing the city (even if it has been already destroyed) with the most number of remained cities in a radius. But WA#14. Please, would you share any AC idea? My bruteforce dies with TL :( There should be some optimizations. Edited by author 22.03.2011 12:31 Finally AC. Yes brootforce rules here. But it's a little BIT tricky brootforce. Edited by author 22.03.2011 12:39 Idea: Graph, Minimal inner stable subset, algo of Bron - Kerboach(effective brute force) oh..(my God!?) Idea: Graph, Minimal dominating set of vertices, problem of set covering, simplest brute force stack searching with table of covering reducing, easy AC By the way! To admin!. It is interesting to make competiton on one problem only(which is NP): minimal covering collection of sets. This algo is very helpfull in practice. Edited by author 25.03.2011 11:10 Could you explain the meaning of this "table of covering reducing"& I've never heard about it. My BF gives TL 10 :( By the way, isn't the problem #1739 - Faryuks based on minimal covering collection of sets algo, as you want? "table of covering reducing"- my term(auto trans. is used) Classical algo for minimal covering had good success in this problem and under emotion I wrote that helping. Again: we have NP problem but can to speed up. So, in stack data we add matrix of covering for example as 1 0 1 0 0 1 1 1 0 1 1 1 This means that 4 points(columns) are covered by 3 sets(rows). First point is covered by only 1-th row and we must use Set-1 as obligatory. Thus, the search tree hasn't branching in this-time vertex and we create only one child vertex with reduced matrix: 1 1 1 1 because 1,3 points are covered by obligated row 1. Finally: when we make choice for some set in search tree we transfer in child vertex reduced matrix. P.S. I had expirience in this algo from boolean design(all practice problem are NP). Re: Ideas Fetisov Alex [Psych Up club] 28 фев 2012 13:46 I did really stupid brute with simple speed up, like bit mask for graph and degree sorting for each connected component. AC with 0.3 seconds. to: svr could you send me your solution of this problem, please? :D my mail: night10101@yahoo.com Edited by author 30.10.2012 22:29 SVR, please, can you tell me, how can you use idea of Bron - Kerboach algorithm and inner stable subset into this problem? It's really interesting and surprising for me. How to use Bron - Kerboach for finding Minimal Dominating Set? Or how to reinterpret problem for searching inner stable subset? |
| file handling. | bright | 1414. Астрономическая база данных | 13 янв 2015 11:57 | 1 |
is file handling is necessary in this problem or not?.. |
| I have WA#1 | Dembel {AESC USU} | 1468. Дробь | 12 янв 2015 22:27 | 12 |
for input "10000 9999 10" my prog gives "1.(0001)". But I have WA#1. help me! Edited by author 25.12.2006 11:40 And what about 1000 9999 10 ? Good luck! Fixed. Dembel {AESC USU} 25 дек 2006 21:56 Correct answer is 0.1(0001),isn't it? Thank you. but I have WA#1. Please give me some test or hint Edited by author 25.12.2006 22:02 Input 9800 9999 10 0 0 output 0.98(0098) or 0.9(8009) input 4 4095 4 1 9999 10 10 9999 10 100 9999 10 1000 9999 10 10000 9999 10 9800 9999 10 3 2 8 0 0 output 0.00001(000001) 0.(0001) 0.001(0001) 0.01(0001) 0.1(0001) 1.(0001) 0.9(8009) 1.4 this output is correct,isn't it? Re: is it true? C-- AESC USU {Kurpilyanskij Gein Parfenenkov} 25 дек 2006 23:38 Correct output 0.(000010) 0.(0001) 0.(0010) 0.(0100) 0.(1000) 1.(0001) 0.(9800) 1.4 I have checked all the anwers in this post all are working fine and sample input is working fine still I got WA1?? Any idea for test1... please provide some rigourous test Thank you!AC now! Edited by author 12.01.2015 23:19 Correct answer for "1000 9999 10" is 0.(1000), not 0.1(0001). In another example 0.(9800) is correct, not 0.98(0098). Re: What answer C-- AESC USU {Kurpilyanskij Gein Parfenenkov} 25 дек 2006 23:34 Edited by author 25.12.2006 23:41 why? 'The output must not contain insignificant zeros.' 0.(1000) contain 3 zeroes on the end, don't it? sorry bad English. Edited by author 25.12.2006 23:42 |
| Explain example test case | rohit | 1468. Дробь | 12 янв 2015 22:26 | 2 |
For the case, 2794 6083 23 2794/6083, I get 0.4593128390596745027124 (in decimal) But when I convert 0.ACM from base 23, I get 0.459275088353744 (in decimal) Where is the mistake ? 2794 6083 23 reason:The correct result:0.ACMACMACMACM...........ACM....... (loop) |
| c++ AC | amirshir | 1581. Работа в команде | 11 янв 2015 23:19 | 1 |
c++ AC amirshir 11 янв 2015 23:19 #include <iostream> using namespace std; int main() { int n ; cin>>n ; int f,s,l ; for(int i=0;i<n;i++) { cin>>s ; if(i==0) { l=s ; f=1 ; } else if(l!=s) { cout<<f<<" "<<l<<" " ; f=1 ; l=s ; } else f++ ; } cout<<f<<" "<<l ; } |
| Some hint about this problem. | Y.Y.M. | 1045. Забавная игра | 11 янв 2015 11:03 | 2 |
1. If we regard the start airport as the root,it is clear that the graph is a tree. 2. If start from all the leaf airport that from one airport could win, start from this airport suerly will lose. Otherwise,he could win. 3. We use a flag to record start from one airport will win or not.Just DFS to obtain all flag. In this way,you could get AC in O(e). Is there any better way to solve this problem? I think the answer is yes. So,could you write down your thought? I didn't want to create new thread, so I will just revive this thread. My idead was to use simple minimax algorithm: boolean firstWins(node v) for every neighbour u of node v check secondWins(u) return true if for some u second loses return false boolean secondWins(node v) for every neighbour u of node v check firstWins(u) return true if for some u first loses return false Hope it will be helpful to someone. Edited by author 11.01.2015 11:04 |
| Help!! WA test 9 | tinrodriguez | 1837. Число Исенбаева | 11 янв 2015 05:21 | 1 |
|