Common BoardI've just brute-forced answers for N = 2...500 and found the trick. But how to prove it is always correct or, at least, for the given binary sequences? Yes, there is a proof. Your e-mail, please. Brute force answers for N = 2.. 500 is a vary good hint for this problem ). Thank you. What is test 8? I tested my program for 9<=n<=200 brute force and my answers is right. For 1<=n<=8 output is: i : NO when i<=n-1 n: aaaaaaaa (n times) This is not true for n = 8. The correct answer is: 1 : NO 2 : NO 3 : NO 4 : NO 5 : NO 6 : NO 7 : aababbaa 8 : aaaaaaaa Thanks! I got AC! My error: I found solution for n<=8 by hand. The test is "abcdeedcbaabcdeedcba"(without quotes). The answer should be ""(empty string). hey mi anwser code is the same, what is the bug hey if one else to know print the anser plese say me..in the test #4 i have a empty string, but the judge say me "wa" in test #4.... why??? help me please. #include <bits/stdc++.h> using namespace std; int main(){ string cad,res; cin>>cad; res = ""; int tam = cad.length(); int i,j; i=0; j=1; int boolean[tam]={0}; while(j<tam){ if(cad[i]==cad[j]){ boolean[i] = 1; boolean[j] = 1; if(i-1>=0){ i-=1; j+=1; }else{ i=j+1; j+=2; } }else{ i=j; j+=1; } } for(int i=0;i<tam;i++){ if(boolean[i]==0) res+=cad[i]; } cout<<res; return 0; } My algo generate array like [1, -1, 2, -2, 3, -3 ...,0], but i got WA27 Any suggetion's? (Bad english) Edited by author 25.08.2016 23:47 You need array like [..., -3, 3, -2, 2, -1, 1, 0], i.e. move all zeros to the beginning of your array, and you'll get AC. Edited by author 26.08.2016 12:12 I don't understand why, but it does not work anyway. Should be output be like 0 1 -1 2 -2 3 -3 4 -4....? My AC program gives answers like (0...0 1 -1 2 -2 3 -3...), but your one - (0 1 -1 2 -2 3 -3 ... n -n ... -n), as I understand. Do you see the difference? 1. Answer always exists. 2. Use DFS for all unmarked vertices and mark them: if current vertex is marked as x, all next must be marked as (x + 1) % 2. (0->1, 1->0) 3. Then just print all vertices marked by 0 (or 1). Edited by author 26.06.2010 04:17 I think, it doesn't need to use DFS. If the edge hasn't incident edges that belong to the first team, we add this edge to the fisrt team. That's all:) If someone has no friends, there is no answer !! I think, it doesn't need to use DFS. If the edge hasn't incident edges that belong to the first team, we add this edge to the fisrt team. That's all:) Thanks, you very helped me) Don't use std::unordered_set as a hash table in C++. There is a test against it, so you'd better use your own hash table or use std::bitset. Edited by author 27.08.2016 13:09 Edited by author 27.08.2016 13:09 Try test with t = 8 and s >= 2 недавно столкнулся с проблемой того что необходимо сохранять некоторыерешения на компьютер если для этого какие нибуть програмки? Самое банальное-создать txt файл и скопировать АС-решение в него. Можно сохранить и в папке,где находится ваше ide( например FreePascal ). using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Soap; using System.IO; namespace _2033 { class Device { public string Friend { get; set; } public string Name { get; set; } public int Cost { get; set; } } class Program { static void Main() {
List<Device> objList = new List<Device>(); for (int i = 0; i < 6; i++) objList.Add(new Device { Friend = Console.ReadLine(), Name = Console.ReadLine(), Cost = int.Parse(Console.ReadLine()) });
// 1. Находим девайс, который находится у большинства парней var query = from list in objList group list by list.Name into grouping orderby grouping.Count () descending where grouping.Count()>=2 select new {grouping.Key,PRCNT= grouping.Count ()} ; string Device = ""; int prev_cnt = 0; bool isFind = true; foreach (var item in query) { if (prev_cnt != 0 && item.PRCNT == prev_cnt) { isFind = false; break; } else if (prev_cnt >= 2 && item.PRCNT<prev_cnt) break; Device = item.Key; prev_cnt = item.PRCNT; } if (Device != "" && isFind) { Console.WriteLine(Device); return; }
//Если таких устройств несколько , то находим самое дешевое из них var query2 = objList.OrderBy(dev => dev.Cost); foreach (var item in query2) { Console.WriteLine(item.Name); return; } } } } Samples: 1 201 405 Should be 99(2) + (3) 1 301 907 Should be 99(3) + (4) 1 448 2824 Should output something large, but the solution definitely exists :) Edited by author 26.08.2016 07:23 Sample numbers have different value of math.sqrt() in last digit. Why? This task is not so big level for hidden problem. sample result: 2297.0716 936297014.1164 0.0000 37.7757 my result: 2297.0715 936297024.0000 0.0000 37.7757 import java.io.PrintWriter; import java.util.Scanner; import java.util.*; public class AlgorithmTAsk { public static void main(String[] arg){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); ArrayList<Float> f = new ArrayList<Float>(); while (in.hasNextLong()) { f.add((float) Math.sqrt(in.nextLong())); } for(int i = f.size()-1;i>=0;i--){ out.printf("%8.6f\n",f.get(i)); } out.flush(); } } Edited by author 19.04.2016 19:45 Try double instead of float import java.util.Scanner; import java.text.DecimalFormat; import java.lang.StringBuffer; import java.lang.Math; public class Timus2{ public static void main(String[] args){ Scanner S = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#.0000"); StringBuffer result = new StringBuffer(); while(S.hasNext()){ result.append(df.format(Math.sqrt(S.nextDouble())) + "\n"); } S.close(); System.out.println(result); } } 1) Any advantages of using "StringBuffer result"? Is it really faster then just print result line by line? 2) Show here expected output, your program output, compare. in prims algo implementation using priority queue, how can i decrease a key in priority queue ? you can't change the element. you have to make your own min-heap for the dijkistra I got AC on VB .NET 2010 !!! Write me on mail saucy_smile@mail.ru and I'll send you the source code :-) Edited by author 24.08.2016 08:07 Edited by author 24.08.2016 08:08 Please check the 12-th test. I and others thinks that our solutions are correct, but they are WA on 12... Maybe anyone can give a little hint? Edited by author 03.08.2006 16:49 Thank you! :) But it is not helped me. Maybe you give me this test? Or any similar? Yeah, I have WA12 too. I doubt if the test is really correct. And one more question: what means pluses and minuses in brackets? (Sorry for offtop). Edited by author 03.08.2006 22:16 Edited by author 03.08.2006 22:16 Cool men write (-) if there are only theme in post, and (+) if it consists any more than ony theme :) It seems that 12 test has cases like 1e14234320000000 2 Is that output would be correct for this case: 1.00e14234320000000 Edited by author 04.08.2006 01:42 12 test has cases like 1e-14234320000000 2 and correct answer for this case: 0.00 From my code: if( exp > 1000 ) ... // make Output Limit The result is Output Limit, test 12! So, exp is more than 1000 :) From problem statement: "It is guaranteed that a length of a result will not exceed 200 symbols." Is it right (with such big exp and number != 0)? No, that was bug in my check code. Later I submited smth like that: if (e>1000 && !isnull(mantissa)) while (1); and this code didn't cause tle. I had the code: if( abs( exp ) > 1000 ) ... // the answer is 0.0000... It got WA 12. Then I decided to divide it into two parts: exp>1000 and exp<-1000. if( exp < -1000 ) ... // 0.000... - 100%, yes? else if( exp > 1000 ) { // I amn't sure that there can be such a situation, that's why I do only output limit while( 1 ) cout << "111\n"; } Output Limit 12! "It is guaranteed the the length of output would be less than 200 symbols". I think, exp>1000 can be only when the number is 0 ( 0e10000 ). But then the right answer is 0.000 - the first code, which gets WA. So, there is a test in 12th test where exp>1000 and number is NOT 0! You forget that input file may contain a number of test cases. Maybe cases with big (and small) exponent your program processes correctly, but fails at other cases. Although i agree that it is very, very strange. There are tests like 1e+00000000000000001 5 or 1e-10000000000000000 2 First, my program had WA on test 12. Than I fixed my bug with this tests, and finally got AC=) my program processes correctly these cases, outputing: 10.00000 0.00 but still wa#12 Try this test: 1+10 0 # it's not a correct float number I got AC when add: if (Regex.Match(val, "[\\+\\-]?([0-9]*\\.)?[0-9]+([eE]?[\\+\\-]?[0-9]+)?", RegexOptions.Singleline).Value != val) { Console.WriteLine("Not a floating point number"); } No, the correct expression is @"^[+-]?([0-9]*\.)?[0-9]+([eE][+-]?[0-9]+)?$" without "?" after [eE] Your expression fails this test: 1+10 0 # The correct answer is "Not a floating point number" Hello! If you have WA 5, pay attention to the fact, that some programmer could take part in contests in more than 3 comands, even in all. Got AC if you WA #9 try this 0.00000000000e10 5 0.00000000001e10 5 I have WA #9 and I have tried this test. But my answer is correct: 0.00000 0.10000 Try this -0.0000010e+6 0 Correct answer is -1 Hello everybody! I wanted to share with you a little site that I made: http://acmtimusru.appspot.com with two additional ranklists: (1) countries ranklist: to compare countries between them by: rating, users, problems solved and activity = last ac; clicking on each country will get you to (2); (2) authors by country ranklist: to compare yourself with other people from your country. This site looks exactly like the acm.timus.ru site, with all links pointing to acm.timus.ru, except for the top red link that points to the countries ranklist. I hope you'll find this useful. I know this site will get deprecated as soon as the admins will create these ranklists on acm.timus.ru, but I had fun building it and learning something new (google app engine). Hello everybody! I wanted to share with you a little site that I made: http://acmtimusru.appspot.com with two additional ranklists: (1) countries ranklist: to compare countries between them by: rating, users, problems solved and activity = last ac; clicking on each country will get you to (2); (2) authors by country ranklist: to compare yourself with other people from your country. This site looks exactly like the acm.timus.ru site, with all links pointing to acm.timus.ru, except for the top red link that points to the countries ranklist. I hope you'll find this useful. I know this site will get deprecated as soon as the admins will create these ranklists on acm.timus.ru, but I had fun building it and learning something new (google app engine). Thank u so much... Great job, man. Hi! Can you share me your code? Or/And Can you tell me, every when update the lists? Thank you! |
|