Common Board| Show all threads Hide all threads Show all messages Hide all messages | | What's wrong? help please! | Rezik | 1021. Sacrament of the Sum | 25 Sep 2016 15:57 | 1 | Edited by author 25.09.2016 18:07 | | I understand test | __Andrewy__ | 1817. Merry-go-round | 25 Sep 2016 12:55 | 1 | Let n=4 and i-1=2. Why ans is 0.687500? We have 6 variants: (carousel moves to the "left") 0011 => Waiting time = 0+0+2+1=3 Conditional expectation(0011) = 0*(1/4)+0*(1/4)+2*(1/4)+1*(1/4)=3/4 Probality(0011)=(1/4)*(2/4)+(1/4)*(1/4)=3/16 0101 => Waiting time = 0+1+0+1=2 Conditional expectation(0101) = 0*(1/4)+1*(1/4)+0*(1/4)+1*(1/4)=2/4 Probality(0101)=(1/4)*(1/4)+(1/4)*(1/4)=2/16 0110 => Waiting time = 0+2+1+0=3 Conditional expectation(0110) = 0*(1/4)+2*(1/4)+1*(1/4)+0*(1/4)=3/4 Probality(0110)=(1/4)*(1/4)+(1/4)*(2/4)=3/16 1001 => Waiting time = 1+0+0+2=3 Conditional expectation(1001) = 1*(1/4)+0*(1/4)+0*(1/4)+2*(1/4)=3/4 Probality(1001)=(1/4)*(1/4)+(1/4)*(2/4)=3/16 1010 => Waiting time = 1+0+1+0=2 Conditional expectation(1010) = 1*(1/4)+0*(1/4)+1*(1/4)+0*(1/4)=2/4 Probality(1010)=(1/4)*(1/4)+(1/4)*(1/4)=2/16 1100 => Waiting time = 2+1+0+0=3 Conditional expectation(1100) = 2*(1/4)+1*(1/4)+0*(1/4)+0*(1/4)=3/4 Probality(1100)=(1/4)*(2/4)+(1/4)*(1/4)=3/16 ans = Expected value = Sum(Conditional expectation(mask) * Probality(mask)) ans = (3/4)*(3/16)+(2/4)*(2/16)+(3/4)*(3/16)+(3/4)*(3/16)+(2/4)*(2/16)+(3/4)*(3/16)=(3/4)*(3/16)*4+(2/4)*(2/16)*2=3*(3/16)+2*(2/16)=11/16. Edited by author 21.06.2017 12:40 | | No subject | Ilyos Yuldoshev | 1984. Dummy Guy | 24 Sep 2016 12:00 | 1 | | | No subject | Ilyos Yuldoshev | 1984. Dummy Guy | 24 Sep 2016 12:00 | 1 | | | should I print YES for the string (**)*) ? | thwomass | 1027. D++ Again | 24 Sep 2016 03:55 | 5 | the problem says that comments may contain every symbol so, comments may contain *) so, should take the *) as we like so it will match as good as we can, or should we take *) as we meet it in the text? #include<stdio.h> char ch; int sem = 0; char str[16] = "=+-*/0123456789"; int search(char c) { int i; for(i = 0; i < 15; i++) if(c == str[i]) return 0; return 1; } void getChar() { scanf("%c", &ch); } void comment() { while(1) { getChar(); while(ch == '*') { getChar(); if(ch == ')') return; } if(feof(stdin)) { sem = 1; return; } } } void expr() { while(ch != ')') { if(search(ch)) { if(ch == ')') return; else if(ch == '(') { getChar(); if(ch == '*') comment(); else expr(); } else sem = 1; } getChar(); if(feof(stdin)) { sem = 1; return; } } } int main() { do { getChar(); if(feof(stdin)) break; if(ch == '(') { getChar(); if(ch == '*') { comment(); } else expr(); } else if(ch == ')') { sem = 1; break; } } while(!feof(stdin)); if(sem) printf("NO\n"); else printf("YES\n"); return 0; } Edited by author 09.07.2004 18:43 Try test: (1+2+3 ) Your program will print NO, but true answer is YES. You must control '\n'... I had same problem... | | WA #18 | Sq1 | 1342. Enterprise | 24 Sep 2016 01:50 | 1 | try changing the float to long double | | Какая ирония. | Akhmat | 1395. Pascal vs. C++. Version 2 | 23 Sep 2016 15:59 | 2 | Задачу нельзя сдать на Java, несмотря на условие | | If you have WA #3 | Smilodon_am [Obninsk INPE] | 2098. Lada Priora | 23 Sep 2016 15:49 | 1 | When you have WA #3, perhaps you check condition in integer values, so use 64-bit integer values. To avoid WA #3 try below test: 100000 10000 10000 100 100 Correct answer is: Cash 51400000.00 Good luck! | | Milking Cows problem, why wrong? | Junhai Feng | | 23 Sep 2016 07:00 | 2 | Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends at time 1200. The third farmer begins at time 1500 and ends at time 2100. The longest continuous time during which at least one farmer was milking a cow was 900 seconds (from 300 to 1200). The longest time no milking was done, between the beginning and the ending of all milking, was 300 seconds (1500 minus 1200). Your job is to write a program that will examine a list of beginning and ending times for N (1 <= N <= 5000) farmers milking N cows and compute (in seconds): •The longest time interval at least one cow was milked. •The longest time interval (after milking starts) during which no cows were being milked. PROGRAM NAME: milk2 INPUT FORMAT Line 1: The single integer Lines 2..N+1: Two non-negative integers less than 1000000, the starting and ending time in seconds after 0500 SAMPLE INPUT (file milk2.in) 3 300 1000 700 1200 1500 2100 OUTPUT FORMAT A single line with two integers that represent the longest continuous time of milking and the longest idle time. SAMPLE OUTPUT (file milk2.out) 900 300 =======following is C code================== #include <stdio.h> void doSort(long nums[5000][2],int n); int main(int argc){ long nums[5000][2]; long max_line[2],cur_line[2],max_gap; int n,i,j;
scanf("%d",&n); for (i=0;i<n;i++){ scanf("%d",&nums[i][0]); scanf("%d",&nums[i][1]); } doSort(nums,n); max_line[0] = nums[0][0]; max_line[1] = nums[0][1];
cur_line[0] = nums[0][0]; cur_line[1] = nums[0][1]; //printf("%d,%d\n",nums[0][0],nums[0][1]); for (j=1;j<n;j++){
// case of line if (nums[j][0] <= cur_line[1] ){ if (nums[j][1]>cur_line[1]){ // line be extended cur_line[1] = nums[j][1]; } // printf("l:%d,%d\n",nums[j][0],nums[j][1]); } else{ // case of gap // get gap value if ((nums[j][0] - cur_line[1])> max_gap){ max_gap = nums[j][0] - cur_line[1]; }
// save current line into max line if cur > max if ((cur_line[1] - cur_line[0] )> (max_line[1] - max_line[0])) { max_line[0] = cur_line[0]; max_line[1] = cur_line[1]; } cur_line[0] = nums[j][0]; cur_line[1] = nums[j][1]; // printf("g:%d,%d\n",nums[j][0],nums[j][1]); } } // save current line into max line if cur > max if ((cur_line[1] - cur_line[0] )> (max_line[1] - max_line[0])) { max_line[0] = cur_line[0]; max_line[1] = cur_line[1]; }
printf("%d ",max_line[1]-max_line[0]); printf("%d",max_gap); return 0; } void doSort(long nums[5000][2],int n){ int j,p; int temp[2]; for (p=1;p<n;p++){ temp[0] = nums[p][0]; temp[1] = nums[p][1]; for(j=p;j>0 && nums[j-1][0] > temp[0];j--){ nums[j][0]=nums[j-1][0]; nums[j][1]=nums[j-1][1]; } nums[j][0]=temp[0]; nums[j][1]=temp[1]; } } tried test case: 6 3000 4000 3000 3500 3500 3600 3000 4500 5000 10000 1000 2000 out put : 5000 1000 I think this case is sucessful, but Judge site gave me the feedback:Wrong Answer! I do not know which test case was not passed..<Judge site does not feedback more detail info> | | what is test case 2 ? | Saif ullah | 1014. Product of Digits | 22 Sep 2016 11:34 | 3 | can anyone please tell me what is test case 2 | | can you tell me why it is wrong? | xinxin | 2033. Devices | 20 Sep 2016 19:28 | 1 | #include<stdio.h.> #include<string.h> int main() { int i,j,temp,re,q; int a[6]={0,0,0,0,0,0}; int b[6]; char c[6][20]; for(i=0;i<6;i++) { char d[20]; scanf("%s",d); scanf("%s",c[i]); scanf("%d",&b[i]); } for(i=0;i<6;i++) { for(j=0;j<6;j++) { if(strcmp(c[j],c[i])==0) a[i]++; } }
temp=a[0]; re=b[0]; for(i=0;i<6;i++) { if((a[i]>temp)||((a[i]==temp)&&b[i]<=re)) { temp=a[i]; re=b[i]; q=i; } }
printf("%s",c[q]); fflush(stdin); getchar(); return 0; }
| | WA test 3 | Lament of the Highborne | 1713. Key Substrings | 20 Sep 2016 07:35 | 1 | WA test 3 Lament of the Highborne 20 Sep 2016 07:35 I got WA on test 3 and cant find error on my code despire of using lots of random test. I using suffix array and lcp. Can anyone give me any test to check :( | | Wrong answer 1 | Tanka | 1000. A+B Problem | 19 Sep 2016 21:56 | 4 | program z1000; var a,b:integer; begin write('Vvedite a b: '); read(a,b); write('a+b= ',a+b); end. Why 'Wrong answer 1' ? Output only number: writeln(a+b); Mr. Aman, please don't post working code or links to working code too. Also your account without any submitted code but with links to above site is very strange. | | Хэлп, пипл! | __Andrewy__ | 1962. In Chinese Restaurant | 19 Sep 2016 19:12 | 1 | Wa9. Хотелось бы несколько наглядных тестов или указание на ошибку в решении. Решение: 1)n<=2 => ans=1 2)n>=3; если есть вершина степени >=3 => ans=0 иначе в графе (неориентированном) есть либо циклы, либо цепи, причём они не пересекаются (т.е. от цикла ни одна цепь не отходит) а)пусть найден некоторый цикл если его длина = n => ans=2 иначе ans=0 б)циклов нет пусть p-общее число цепей в графе, len(i)-длина i цепи если len(i)>2 то положим len(i)=2 => ans=len(1)*len(2)*...*len(p)*(p-1)! Edited by author 19.09.2016 19:13 Edited by author 19.09.2016 19:34 Edited by author 29.10.2016 23:21 | | Runtime error (access violation) Please help me !! sad...... | xinxin | 1100. Final Standings | 19 Sep 2016 11:35 | 5 | #include<stdio.h> void merge(int a[],int b[],int c[],int d[],int left,int mid,int right) { int i=left,j=mid+1; int k=left; while((i<=mid)&&(j<=right)) { if(a[i]>=a[j]) {b[k++]=a[i++]; k--; i--; d[k++]=c[i++];} else {b[k++]=a[j++]; k--; j--; d[k++]=c[j++];} } if(i>mid) for(int q=j;q<=right;q++) {b[k++]=a[q]; k--; d[k++]=c[q]; } else if(j>right) for(int q=i;q<=mid;q++) {b[k++]=a[q]; k--; d[k++]=c[q];} for (int l = left;l <= mid;l++) { a[l] = b[l]; c[l]=d[l]; } for (int l = mid+1;l <= right;l++) { a[l] = b[l]; c[l]=d[l]; } } void mergesort(int a[],int b[],int c[],int d[],int left,int right) { if(left<right) { int mid = (left + right) / 2; mergesort(a,b,c,d,left,mid); mergesort(a,b,c,d,mid+1,right); merge(a, b,c,d, left, mid, right); } } int main() { int n,i; int c[15000],a[15000],b[15000],d[15000]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&c[i]);
scanf("%d",&a[i]); } mergesort(a,b,c,d,0,n-1); for(i=0;i<n;i++) { printf("%d %d\n",d[i],b[i]); } fflush(stdin); getchar(); return 0; } I will solve all your issues with all your current non-AC tasks just for 0.01BTC :> Sorry then :) Anyways, feel free to look into older threads of corresponding tasks, they might contain hints for your questions. | | answers for 528932, 386891557, 19362 | Михаил Аршинов | 1261. Tips | 17 Sep 2016 22:57 | 2 | 708591 179659 (or 531444 2512) 387600148 708591 (or 387423001 531444) 19686 324 These answers are right too: 528932 => 531480 2548 386891557 => 387686170 794613 19362 => 19723 361 | | Tip for WA2 - wrong limits | Juve45 | 1167. Bicolored Horses | 17 Sep 2016 14:21 | 1 | I got WA2, but after that I changed limits for N and K from 501 to 503 and it worked. (indexing starting from 1). | | why it is wrong answer???sad... | xinxin | 1607. Taxi | 16 Sep 2016 20:04 | 1 | #include<stdio.h> #include<math.h> int main() { int a,b,c,d,i,t; scanf("%d %d %d %d",&a,&b,&c,&d);
for(i=1;i<10000;i++) { a=a+b; if(a>c) { t=c; break; } c=c-d; if(a>=c) { t=a; break; } } printf("%d",t); return 0; } | | Always got Runtime Error at test2 | Alain | 1039. Anniversary Party | 16 Sep 2016 05:31 | 2 | Any idea about this test? I used Python2.7 | | WA8 | 💻Evgeny Nemtsev [UrFU FT-17] | 1543. Dance Revolution | 16 Sep 2016 00:41 | 1 | WA8 💻Evgeny Nemtsev [UrFU FT-17] 16 Sep 2016 00:41 Долго не мог понять, в чём проблема. Не используйте вещественные типы, всё должно быть целочисленное, нельзя даже умножать период на 0.4 и 0.7, лучше домножить на 10. Может кому-то это поможет... |
|
|