Common Boardtanx... Edited by author 07.11.2008 21:32 "a <= b" -> "a < b+eps" "a < b" -> "a < b-eps" eps = 1e-8 was enough for this prolem I use you hint... but I got wa#16 :( Some tests 10 10 1 9 6 NO 10 10 1 9 7 YES Can you explain why the second answer is YES. Need it badly #define I(x) int x; cin >> x #define F(i,n) for(int i = 0; i < (n); ++i) int main(){ cin.sync_with_stdio(false); I(n); I(k); I(m); cout << "YES" << endl; F(i,k){ I(s); F(i,s){ I(x); //... 1. Инициализация Начинайте с 1 конюшни Пусть нам надо поставить туда I лошадей (I = 1..N) Коэффициент несчастья для I лошадей будет при этом равен White * Black для Horses = 0..i По итогу этого у нас будут оптимальные (потому что единственные) коэффициенты для всех лошадей в случае 1 конюшни 2. Итерации (меняем J-ую конюшню) Надо рассчитать минимальный коэффициент несчастья если в 1..J конюшни поставить I лошадей Для этого переберём все варианты, поставив в J конюшню K лошадей (K = 1..I лошади) и оптимально заполнив первые J-1 конюшни I-K лошадьми (этот коэффициент у нас уже рассчитан на предыдущем шаге итерации) Перебрав все варианты у нас получится оптимальное заполнение первых J конюшен первыми I лошадьми Переходим к J + 1 конюшне и считаем заново все варианты заполнения уже для неё Hi, I had an accepted solution 3 years ago and now I have no idea what was wrong/right. Looking at my previous solution that now gets TLE, it was Kuhn matching algorithm. Did the constraints change or did you just add better tests? OK, I have no idea how could I possibly come up with such solution and how come it passed the tests before :P I found my mistake. I have AC. Edited by author 12.12.2010 15:33 What was the problem? Test TTGgtAatTGgt 1 6 11 turned out to be helpful. I got AC with #define I(x) int x; cin >> x #define F(i,n) for(int i = 0; i < (n); ++i) int main(){ cin.sync_with_stdio(false); I(n); I(m); F(i,n){ string w; cin >> w; I(j); auto& c = clones[j-1]; if(w == "learn"){ // ... For wa#3: 4 0 0 3 0 0 YES For wa#4 0 0 5 0 6 5 YES For wa#5 0 0 4 0 2 3 The possible answer is: NO 0.00000000000000000000 0.00000000000000000000 4.00000000000000000000 0.00000000000000000000 0.46153846153846145000 0.69230769230769285000 But i still have have wa#31. I think, I have problem with precision. Can anyone tell me how to avoid this problem? UPD: Finaly AC. I think, it realy was a problem with precision, but I am not sure. Edited by author 27.07.2011 22:20 Edited by author 27.07.2011 23:58 Yes, problem in precision. EPS = 1e-10 AC EPS = 1e-11 WA#36 Could someone help me ? #include <iostream> #include <iomanip> using namespace std; int main() { double outputNumbers[100000]; double number; int index; index = -1; while (cin.fail() == false) { cin >> outputNumbers[++index]; }
cout << fixed; cout << setprecision(4);
while (index > 0) { cout << sqrt(outputNumbers[--index]) << endl; } return 0; } I have rewrite the program, using vectors but now I receive wrong answer... #include <iostream> #include <iomanip> #include <vector> using namespace std; int main() { vector<double> myVector; double value; while (cin.fail() == false) { cin >> value; myVector.push_back(sqrt(value)); }
myVector.pop_back(); cout << fixed; cout << setprecision(4); for (int i = 0; i < myVector.size(); i++) { cout << myVector[i] << endl; } return 0; } My program: Program t1127; Const P:array[1..24,1..6]of integer= {all combinations} ( (6,4,3,1,5,2), (3,5,4,1,6,2), (4,6,5,1,3,2), (5,3,6,1,4,2), (6,4,5,2,3,1), (3,5,6,2,4,1), (4,6,3,2,5,1), (5,3,4,2,6,1), (1,2,6,3,4,5), (6,4,2,3,1,5), (2,1,4,3,6,5), (4,6,1,3,2,5), (1,2,4,5,6,3), (6,4,1,5,2,3), (2,1,6,5,4,3), (4,6,2,5,1,3), (1,2,3,4,5,6), (3,5,2,4,1,6), (2,1,5,4,3,6), (5,3,1,4,2,6), (1,2,5,6,3,4), (3,5,1,6,2,4), (2,1,3,6,5,4), (5,3,2,6,1,4) ); MaxN=1000; Var Cube :array[1..MaxN,1..6]of char; Tmp :array[1..6]of char; ACube :array[1..MaxN,1..24]of string[4]; yet :array[1..MaxN,1..24]of boolean; N,i,j,k :integer; max,ik,jk :integer; m :integer; ch :char; begin Read(n); for i:=1 to N do for j:=1 to 6 do begin read(ch); while (ch=#10)or(ch=#13)or(ch=#32) do read(ch); Cube[i,j]:=ch; end; for i:=1 to N do for j:=1 to 24 do begin for k:=1 to 6 do tmp[k]:=cube[i,p[j,k]]; ACube[i,j]:=''; ACube[i,j]:=tmp[1]+tmp[2]+tmp[3]+tmp[4]; end; m:=0; for i:=1 to N do for j:=1 to 24 do yet[i,j]:=true; for i:=1 to N do for j:=1 to 24 do if yet[i,j] then begin yet[i,j]:=false; max:=1; for ik:=1 to N do if ik<>i then for jk:=1 to 24 do if ((acube[i,j][1]=acube[ik,jk][1])and(acube[i,j][4]=acube[ik,jk] [4]))or ((acube[i,j][1]=acube[ik,jk][4])and(acube[i,j][4]=acube[ik,jk] [1])) then if ((acube[i,j][2]=acube[ik,jk][2])and(acube[i,j][3]=acube[ik,jk] [3]))or ((acube[i,j][2]=acube[ik,jk][3])and(acube[i,j][3]=acube[ik,jk] [2])) then begin yet[ik,jk]:=false; max:=max+1; break; end; if max>m then m:=max; end; writeln(m); end. Think there are more combinations, i did solve this problem, but i don't remind how much, if you want write me :), miguelangelhdz@hotmail.com Good Luck > Think there are more combinations, i did solve this problem, but i > don't remind how much, if you want write me :), > miguelangelhdz@hotmail.com > Good Luck import java.util.Scanner; public class Problem_1881 { public static void main(String[] args) { Scanner in=new Scanner(System.in); int h,w,n,i,p,ans,SL,h1; ans=SL=h1=0; p=-1; ..... Edited by author 22.03.2014 20:32 Can you give me a test similar to the fifth test. Just i dont know where i have endless cycle? Sorry for my english. Why? My code works correctly when it is no "end" in the end and with != qayerda xato qildim ko`zinga achke taqib qara Yaxshilab o`qi va yana o`qi ok? What is wrong with mycode? it is working in mycomputer but failing in test2 import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; /** * Created by sherxon on 3/17/14. */ public class Biathlon { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=Integer.parseInt(in.nextLine()); String s, name, time; Double min, sec; int j=0; List<String> a= new ArrayList(); ArrayList<Double> b= new ArrayList(); int thirty=0; for (int i = 0; i <n ; i++) { s = in.nextLine(); name=s.split(" ")[0]; sec=Double.parseDouble(s.split(" ")[1].split(":")[1])+60*(Double.parseDouble(s.split(" ")[1].split(":")[0])); sec+=thirty; //System.out.println(sec); double eachsec=0.0; double eachsecs=0.0; boolean bl=true; for (int k = 0; k<a.size() ; k++) { // System.out.println(sec-thirty + " " + (b.get(k)-eachsec) + " " +(sec) + " " + b.get(k)); if(sec-thirty<b.get(k)-eachsec&&sec<b.get(k)){ b.remove(k); a.remove(k); k--; } eachsec+=30; } for (int k = 0; k <a.size() ; k++) { if(sec-thirty>b.get(k)-eachsecs){ bl=false; } eachsecs+=30; } if(bl){ a.add(name); b.add(sec); } thirty+=30; } Collections.sort(a); System.out.println(a.size()); for (int i = 0; i <a.size() ; i++) { System.out.println(a.get(i)); } } } Can variables have names "or", "and", "xor", "not", "print", "if", "goto", "end"? Why for test 1 0 1 0 3 1 0 0 answer EF- AE- DH+ CD- EH- is wrong? Could someone publish such testcase with the answer = -1? Edited by author 25.07.2008 18:11 If m and n are even, there is always a solution. I have the same problem and I don't know why. If somebody know this test or some other like that, please show it. I supose that there is only one test... But all what you need is delete one road between 2 points and with help of Deikstra find out the shortest way between this points ... than add length of road and you find out the shortest way throw this row.... and so on! I solved this problem such way! It's O(N^4)! You can optimize this nice idea to reach O(N^3)! here is test 1: 4 6 1 2 40 1 3 50 1 40 60 2 3 10 2 4 30 3 4 20 one answer: 2 3 4 Edited by author 21.10.2005 16:50 Thanks for your test... :) I have AC 0.046 sec... but this problem says: "...In the town there are N crossing points numbered from 1 to N..." here is test 1: 4 6 1 2 40 1 3 50 1 40 60 2 3 10 2 4 30 3 4 20 one answer: 2 3 4 My program prints: 2 4 3 It's true, imho. I think It's : 1 2 40 1 3 50 1 4 60 2 3 10 2 4 30 3 4 20 my ans is 2 3 4,but get WA at Test#1 Impossible. I get 2 3 4 as answer at get wrong answer on #1 Floyd Algrathm is also advisable. However, please take note of another test: 4 4 1 2 10 2 3 1 3 4 1 4 1 1 should output things like 1 4 3 2 but NOT 1 4 3 4 So I've made an embarrassingly large number of submissions for this problem. Thing is I submitted in C++ 11 and got WA 1. Afterwards I switched to Visual C++/G++ and got WA 2. Apparently this was caused by asserts that I had left in my program to check if test 1 is actually the example. After I removed them I got Accepted, but still WA 1 in C++11. So my questions would be: 1. Why did it get WA in C++ 11? 2. Why didn't the assert crash the program? |
|