| Show all threads Hide all threads Show all messages Hide all messages |
| If you are C++ programmers, priority_queue<unsigned int> is very easy. | Megatron | 1306. Sequence Median | 8 Nov 2012 20:09 | 2 |
Although I don't use C++, but I also can use heap to solve it. |
| Anti-WA22 Test | bsu.mmf.team | 1911. Titan Ruins: Overtaking Fire | 8 Nov 2012 14:54 | 6 |
This problem is not difficult. A lot of people got long sequences of WA#22 (as well as I did) because of one very stupid mistake. I hope this test will help to understand this mistake: 10 10 20 10 100 1 2012 10000 1 30 60 Answer: 15000.0000000 Thanks for the test. I get a different answer (and have WA22) -- 14000. To get your answer from my calculations you're either stopping the cart in the tunnel (which should never be necessary I think) or you're getting a different value for the time when the fire passes the end of the tunnel. I'm not sure where my mistake is. The cart clearly fully enters the tunnel at time 4, and the back of the fire passes the end of the tunnel at time 9 (the fire does not meet the cart before it fully enters the tunnel). 9-4=5. Covering 20 m over 5 seconds with initial velocity 10 requires deceleration of a = 2.4, which is 1.4 more than 1, thus 14000. I'm assuming the front of the cart can't enter the tunnel into the fire... What's wrong with my reasoning? Edited by author 01.11.2012 12:30 With deceleration 2.4 after 5 seconds in the tunnel a velocity of the cart will be equal 10 - 2.4*5 = -2. Oops :) Haha! That's funny. I just used "s = v * t - 1/2 a * t^2" but forgot to check whether it involved "backing up" :). Sorry to Soren and Alba for barbecuing you before backing you up into the safety of the tunnel! I'm sure they'll forgive you. You are not the first who does that ;) It's very funny that this fact didn't allow to solve the problem anybody who tried to do it during the contest. Edited by author 02.11.2012 12:14 At long last, AC. Lots of little details to pay attention to in this one! |
| what WA#22 ? | DENISKA(SSAU) | 1821. Biathlon | 7 Nov 2012 22:18 | 2 |
|
| some hints | zoid | 1826. Minefield | 7 Nov 2012 19:08 | 2 |
can you explain DP parameters? |
| C++ | Pegasus | 1868. Prediction Contest | 7 Nov 2012 15:05 | 1 |
C++ Pegasus 7 Nov 2012 15:05 just use <map> Edited by author 07.11.2012 15:05 |
| We have a correct answer.But why WA#12. | Muhabbat | 1106. Two Teams | 7 Nov 2012 13:36 | 4 |
Input: 7 2 3 0 3 1 0 1 2 4 5 0 3 0 3 0 7 0 6 0 Output: 4 1 4 5 6 Is it true? Please Give me some tests. Edited by author 03.11.2009 15:17 Edited by author 03.11.2009 15:18 I think your answer is true. Try it: In 4 2 0 1 4 0 4 0 2 3 0 Out 2 1 3 or 2 4
Edited by author 06.11.2009 14:49 |
| TL #16 ?!?!???!?! HELPP | h1ci | 1135. Recruits | 7 Nov 2012 12:34 | 2 |
#include <iostream> #include <string> using namespace std; int main() { char s[30001]; int a; cin >> a; for(int i=0; i<a; i++) cin >> s[i]; int res=0; bool ok=false; while(!ok) { ok=true; for(int i=0; i<a-1; i++) { if(s[i]=='>' && s[i+1]=='<') { s[i]='<'; s[i+1]='>'; res++; ok=false; i++; }
} //cout << s << ' ' << ok << endl; } cout << res << endl; return 0; } I used very similar code and got AC (though there is a better solution if I recall correctly). What I did is: - Use stdio instead of iostream: it's faster - If you have <<< at left end or >>> at right and, you can ignore those - they will never change again. Thus, you can keep treack of the left and right endings, and only parse those, instead of going from 0 to n every time. AC 0.625 |
| why tl#15 | vyu | 1135. Recruits | 7 Nov 2012 12:33 | 2 |
#include <iostream> using namespace std; int main() { char x[30005],l='<',r='>',p; int n,i,s=0,k=1; cin>>n; for(i=0; i<n; i++) cin>>x[i]; while(k!=0) { k=0; for(i=0; i<n; i++) if( x[i]==r && x[i+1]==l) { swap(x[i],x[i+1]); s++; k++;} } cout<<s; return 0; } i don't know how to minimize my prog I used very similar code and got AC (though there is a better solution if I recall correctly). What I did is: - Use stdio instead of iostream: it's faster - If you have <<< at left end or >>> at right and, you can ignore those - they will never change again. Thus, you can keep treack of the left and right endings, and only parse those, instead of going from 0 to n every time. AC 0.625 |
| string of limited? | Михаил | 1427. SMS | 7 Nov 2012 11:16 | 1 |
In The documentation that the type of string is not limited to 255 characters. but the program does not pass the second test. Q: Amount of characters is limited or not? or how to make a string of unlimited? |
| sqrt | Amandosov | | 7 Nov 2012 03:12 | 2 |
sqrt Amandosov 7 Nov 2012 03:02 please take me the alternative sqrt, without library |
| Why? | AJProg | 1209. 1, 10, 100, 1000... | 7 Nov 2012 02:39 | 2 |
Why? AJProg 5 Mar 2012 01:09 Could you please explain where this formula comes sqrt (8 * N-7) Edited by author 05.03.2012 01:14 Edited by author 05.03.2012 01:17 Извините, что по-русски. Формула немного другая. Единицы стоят на местах, выражаемых формулой Sn = n*(n+1)/2 + 1, где nэN и n>0. Эта формула получена из соображений арифметической прогрессии. Из этой формулы можно получить, что n = sqrt(2*Sn-1.75) - 0.5 или n = (sqrt(8*Sn-7)-1)/2. Если nэN и n>0, то Sn существует, и на месте Sn стоит единица, иначе - ноль. |
| why wrong answer | Paul | 1025. Democracy in Danger | 6 Nov 2012 23:38 | 6 |
[code deleted] Edited by moderator 20.11.2019 00:12 I have the same problem for example a write: 5 5 5 5 5 5 my program gives me 9 is it true? Edited by author 06.11.2012 21:15 Edited by author 06.11.2012 21:15 and if I write: 4 4 4 4 4 I get 9 too and if I write 5 3 7 6 6 4 I get 9 too i solved problem. i changed from real to word and all OK wht do u mean by real to word nd did ur ques get accept? |
| Hint in Java | xZ_ | 1011. Conductors | 6 Nov 2012 21:18 | 1 |
If you use strictfp flag time will be smaller. For my solution this flag has changed time from 0,109 to 0,093 :) |
| Why crash is happening | Paul | 1025. Democracy in Danger | 6 Nov 2012 20:36 | 1 |
this is my code and its wrking fine on my pc import java.io.*; import java.util.Scanner; public class Democracy { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
Scanner sc = new Scanner (System.in); System.out.println("enter no of groups"); int n = sc.nextInt();
System.out.println("enter group members"); //String s = sc.next(); //String[] num = s.split(","); String[] num = sc.next().split(",");
int[] num1 = new int[num.length]; int x =0; for(String a: num){ num1[x] = Integer.parseInt(a); //System.out.println(a); x++; }
int len = n/2+1; int[] min = new int[len];
for(int i = 0; i <len; i++ ){ min[i] = num1[i]; for(int j= i+1; j<num1.length; j++ ){ if(min[i] > num1[j]){ min[i] = num1[j]; } } }
int vote = 0; for(int i =0; i<len; i++){ vote = vote+ min[i]/2+1; }
System.out.println(vote);
} } |
| Compilation error showing bad class hierarchy but wrking correctly in idle | Paul | 1068. Sum | 6 Nov 2012 17:47 | 1 |
package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Sum {
public static void main(String[] args) { // TODO Auto-generated method stub //Scanner sc = new Scanner (System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int x = 0; int sum = 0; try { x = (int)br.read(); System.out.println("x" +x); if(x >0){ for(int i =1; i <= x ;i++){ sum = sum +i; } } else { for(int i =x; i <=1 ;i++){ sum = sum +i; } }
} catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
System.out.println(sum); } } |
| wa6 pascal | maksimla | 1787. Turn for MEGA | 6 Nov 2012 10:27 | 3 |
var k,n,i,sum,s:integer; begin readln(k,n); sum:=0; for i:=1 to n do begin readln(s); sum:=sum+s-k; if sum<0 then sum:=0; end; //sum:=sum+s-k; //if sum<0 then sum:=0; writeln(sum); readln; end. whot wrong? Edited by author 06.11.2012 01:22 var k,n,i,sum,s:integer; begin readln(k,n); sum:=0; for i:=1 to n do begin read(s); // here must be read. not readln; sum:=sum+s-k; if sum<0 then sum:=0; end; //sum:=sum+s-k; //if sum<0 then sum:=0; writeln(sum); end. whot wrong? |
| What is test n6 | TUIT-Karshi#2 | 1910. Titan Ruins: Hidden Entrance | 5 Nov 2012 17:07 | 2 |
Edited by author 05.11.2012 17:17 Edited by author 05.11.2012 17:17 |
| WA24 and WA30 | Michael Plusnin (USU) | 1919. Titan Ruins: Transformation of Cylinders | 5 Nov 2012 14:48 | 1 |
If you have WA24 then swap(Li, Hi), and if you have WA30 use aspect ratio in a similar triangle)) |
| Why? | Amandosov | 1820. Ural Steaks | 5 Nov 2012 14:33 | 2 |
Why? Amandosov 25 Oct 2012 22:40 #include <iostream> int main() { int n,k,a; std::cin>>n>>k; if ((2*n)%k==0) a=(2*n-(2*n)%k)/k; else a=(2*n-(2*n)%k)/k+1; std::cout<<a; return 0; } wrong answer po4emu ne pravilno, ved algoritm verni? Edited by author 25.10.2012 22:40 Edited by author 25.10.2012 22:40 if ((n%k)*2<=k) {answer=3;} |
| getche function | alirezaARSH | 1197. Lonesome Knight | 4 Nov 2012 17:27 | 3 |
why getche is undefined for compiler.in 'dev c 'i used it and is define program: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i,j,k,s,b,n; char a,c[99][8][8]; scanf("%d",&n); for(k=0;k<n;k++){ a=getche(); scanf("%d",&b); c[k][(int)a-96][b]='n'; }
for(k=0;k<n;k++){ s=0; for(i=1;i<=8;i++) for(j=1;j<=8;j++) {
if(c[k][i][j]=='n'){ if(i+2<=8&&j+1<=8) s++; if(i+2<=8&&j-1>=1) s++; if(i-1>=1&&j+2<=8) s++; if(i-1>=1&&j-2>=1) s++; if(i-2>=1&&j-1>=1) s++; if(i-2>=1&&j+1<=8) s++; if(i+1<=8&&j-2>=1) s++; if(i+1<=8&&j+2<=8) s++; } } printf("\n%d",s); }
system("PAUSE"); return 0; } because getch() and not getche() |