| Show all threads Hide all threads Show all messages Hide all messages |
| Any hint when there is no healers | panyong0202 | 1952. To Kill the Dragon | 20 Jan 2015 15:18 | 2 |
Oh, there are no such cases. There is at least one healer and one attacker. Fixed in statement now. |
| чтение данных | lucshiiiulian | 1026. Questions and Answers | 18 Jan 2015 20:32 | 2 |
алгоритм сделал и работает, но не проходит проверку, говрит что напечатал слишком много букафф,,, мне кажется я неправильно читаю К, не знаю как перепрыгнуть через те решетки :( int K; char ch; scanf("%s%d",&ch,&K); |
| тест 19 | CrispyArty | 2009. Canteen Line | 17 Jan 2015 21:05 | 2 |
тест 19 CrispyArty 29 May 2014 12:39 Не могу понять что не так с 19-ым тестом... Даёт "Wrong anser" хотя я проверил каждую мелочь... кто может помочь? I had this problem too, because of a logic problem... Test: 9 2 0 0 0 0 2 0 2 0 6 0 6 0 8 0 10 6 1 2 3 4 5 6 11 3 7 8 9 Ans: 11 right 11 left 12 right 15 left 14 left 12 left 13 right 13 left 14 right |
| Is sum a_i >= n | Orfest (Novosibirsk SU) | 1964. Chinese Dialects | 17 Jan 2015 20:26 | 2 |
Is it guaranteed that a1+a2+...+ak >= n? |
| Test #5? Whats wrong with my code? | SmolevI | 2023. Donald is a postman | 17 Jan 2015 18:53 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int a[1000]; int n,i,k; char Name; cin>>n; string B; k=0; for (i=0;i<n;i++){ cin>>B; Name=B[0]; if(Name=='A' or Name=='P' or Name=='O' or Name=='R') {a[i]=1;} else {if(Name=='B' or Name=='M' or Name=='S') {a[i]=2;} else {a[i]=3;}; } } k=a[0]-1;
for (i=1;i<n;i++){ if (a[i-i]<a[i]){ k=k+a[i]-a[i-1];} else { k=k+a[i-1]-a[i];}
} cout<<k; return 0;
} |
| Спасибо за задачу | nobik | 1203. Scientific Conference | 17 Jan 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. For Fans of Statistics | 17 Jan 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. Conspiracy Theory and Rebranding | 17 Jan 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. Reverse Root | 16 Jan 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. Awesome Backup System | 15 Jan 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. Pass Licenses | 15 Jan 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. Fire Circle | 15 Jan 2015 16:10 | 2 |
Test 10 Ignat Zakrevsky 13 Feb 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. Labyrinth | 15 Jan 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. Sold Out! | 15 Jan 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. Check a Sequence | 14 Jan 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 | oybek | 1018. Binary Apple Tree | 14 Jan 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. Sum | 14 Jan 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. Adventure Time | 14 Jan 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 Khyzha | 1824. Ifrit Bomber | 13 Jan 2015 19:10 | 10 |
Ideas Artem Khyzha 19 Mar 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). 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 Re: Ideas Oleg Vasilenko (Chelyabinsk) 13 Jan 2015 19:10 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. Astronomical Database | 13 Jan 2015 11:57 | 1 |
is file handling is necessary in this problem or not?.. |