Common Board#include <stdio.h> int p,t,n,m; int main() { scanf("%d%d%d%d",&p,&t,&n,&m); if (p<2 || p>10000 || t<2 || t>200 || (t&1) || n<1 || n>10 || m<1 || m>100) return 1/(p-p); return 0; } This program gets "Crash (integer division by zero)" at test #1. http://acm.timus.ru/status.aspx?space=1&num=1526You are right, m = 0 in the 1st test. This limitation in the problem statement is fixed now. But there is a division by zero in his code! Sandro, why did you delete my post? Because the solution of Yermak is a input validator. If the system verdict on some test is Crash (division by zero), then this test is incorrect. If the test is correct, system verdict should be Wrong Answer. Sandro, look at this line of his code! There is a division by zero if condition is true, because p-p = 0! if (p<2 || p>10000 || t<2 || t>200 || (t&1) || n<1 || n>10 || m<1 || m>100) return 1/(p-p); Edited by author 13.08.2012 11:55 Captain Obvious to the rescue! Noob, oh, i understand. Edited by author 14.08.2012 00:04 is graph just full on 49 test? probably nop , cose i test prog on full 2000 less then .1sec after 2 days, found DP solution, and AC with 0.046 s. Edited by author 15.08.2012 16:07 I tried to read data string by string and then by characters but in both cases I got Crash(access violation) on 1st test :( Edited by author 18.08.2012 20:30 Dear all, all tests I found in this discussion worked, but when I run my code I do have WA on test 7 (or 13 for another version of my code). Can someone please give a kind of inputs with some test? I checked everything I could think of and it worked. Thank you! Input: 4 4 0 3 0 4 0 0 Output: 0101 Thank you for the answer. The following tests are working, but when I submit I do have WA2. I. 3 2 0 3 0 0 result: 010 II. 4 4 0 3 0 4 0 0 result: 0101 III. 5 2 5 0 3 0 4 0 5 0 0 result:-1 IV. 5 2 3 4 5 0 0 0 0 0 result: 01111 V. 6 2 4 6 0 3 5 0 4 6 0 5 0 0 0 result: 010101 VI. 0 result :-1 I am using bfs, of course with a queue implementation. Hmm, but I used dfs and have no problems :) Maybe I will try also dfs. I still do not understand why bfs would not work (well a little modified). It seems that I have now WA#2. Does somebody knows test #2 (except those written above.)? Thank you. I have got accepted with a version of bfs modified. I also found the problem in my implementation. Once I succeeded for test below and all others from above, I got AC. Thank you for your help. 6 2 3 0 4 0 5 0 6 0 6 0 0 result: 011001
Anton Chaplygin [Kungur] [Psych Up club] WA 15 [1] // Problem 1793. Tray 2 11 Aug 2012 20:58 If you have WA15, you should think about the height of the plate and the height of the box. I don't think so. I think about it and I have WA15. use sort, wa. use stable_sort, ac May be w=0 or not? Is it possible? "...weight w (0 ≤ w ≤ 1000)...." I think he broke something in TOJ system because he is banned now :O Edited by author 10.08.2012 14:52 take me idea what is wrong: var a,b,c:integer; begin read(a,b); c:= (2*a) div b; if c=2*a/b then write(c)else write (c+1); end. p.s sorry for my english try test a=1, b - any number. you'll get answer c=1. answer from Anatoly: Reduce pattern parts of "%%%%%%" to "%". It extremely raises performance of regex engine. It's really helps. From TLE #6 to AC A a ans = 0 --------------------- A A ans = 0 --------------------- aB ans = 2 --------------------- asasa.!sds sdsdsd!!!..::dsd ans = 3 --------------------- -a. ans = 1 -------------------- 090aA is a number. ans = 2 -------------------- this sentence have one mistake ans = 1 -------------------- Hello! 238 my Friend ans = 1 -------------------- Asf,.,a ans = 1 -------------------- You guys better use "cin" for solving this problem, because they put some gaps in input data and "scanf" give you WA. Sorry for my poor English. What are the gaps in the input data? Or is this possible: bring 1, bring 2, take 2 away, bring 3, take 3 away, take 1 away? Or what is the answer for 9999 6 1 0 ? 4 or 5? After careful analysis of second sample I concluded that waiter could take away any number of plates. #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> #include<queue> using namespace std; #define N 900000 struct seq { int l; int r; }; seq se[N]; int m; bool cmp(const seq &s1,const seq &s2) { if(s1.l==s2.l) return s1.r>s2.r; return s1.l<s2.l; } int main() { //while(scanf("%d",&m)!=EOF) //{ scanf("%d",&m); int left,right; queue<int>que; while(!que.empty())que.pop(); int i=0,j; while(scanf("%d%d",&left,&right)) { if(left==0&&right==0)break; se[i].l=left; se[i].r=right; i++; } sort(se,se+i,cmp); int rightf=0; int maxlen=0; int num=0; int p=-1; int ff=0; for(j=0;j<i;j++) {
if(se[j].l<=rightf&&se[j].r-rightf>maxlen) { maxlen=se[j].r-rightf; p=j; } else if(p!=-1&&maxlen>0) { que.push(p); rightf=rightf+maxlen; maxlen=0; num++; j=j-1; } if(rightf>=m) { ff=1; break; } } if(maxlen>0) {
rightf=rightf+maxlen; maxlen=0; num++; if(rightf>=m) { que.push(p); ff=1; } } if(ff) { printf("%d\n",num); while(!que.empty()) { int top=que.front(); printf("%d %d\n",se[top].l,se[top].r); que.pop(); } } else printf("No solution\n"); //} return 0; } There is two clusters of planets: first cluster - planets on distance 10, 20, 30 from Betelgeuse, and second - 50, 60. If tourist start with any planet from cluster - he can get to any another planet from this cluster, but can't get to any planet from any another cluster. Every tourist has another restriction: max and min distance to Betelgeuse, so first tourist can visit {10, 20, 30} or {50, 60} in first set only one race, in second set - two races. So answer for first tourist is 2. Second tourist can visit only {20, 30} - one race - answer is 1. AC!!!! :D Don't use overflowing (int64 or int) in your hash function! :D Edited by author 10.08.2012 18:07 |
|