Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | @admin I think #42 is illegal. | William Chou | 1915. Руины титанов: воссоздание былого | 27 июл 2013 11:07 | 4 | The problem say that "It is guaranteed that during the experiment each time a coin was to be removed the stack was not empty." But when I submit such a brute force code: -------------------- if (x > 0) a[t++] = x; else if (x == 0) { if (t + t < maxn) { copy(a, a + t, a + t); t += t; } } else printf("%d\n", a[--t]); -------------------- It crashed at #42. Then, I modified the last "else branch" into: -------------------- else if (t) printf("%d\n", a[--t]); -------------------- I got WA at #42. What if t = maxn/2 + 1 and than t + 1 pop operations? For example: 1000000 1 0 0 .. 0 (20 times) -1 -1 .. -1 (1000000 - 21 times) You will store only 2^19 copies in array, and get crash Oh..Sorry..It's my fault. I only set the size of a to 1000001 * 2, but I forgot to modify the maxn.... I apologize for asking so stupid question.T_T Accepted now, thank you very much. Yeah,I've made the same mistake,and thank you so much! | | WA3 I cant find the error | Arturo | 1723. Книга Сандро | 27 июл 2013 05:49 | 1 | #include<iostream> #include<stdio.h> #include<string.h> using namespace std; char v[53];int ch[53]; char vi[53][5],*punt=NULL,vf[53],vc[53],vp[53],*a,vt[53],chr[3]; int maxl=0,maxt=0,k,b,max2,l=0; int n,j=0,i,ind; main() { gets(v); n=strlen(v); if(n==1){cout<<v;} else{ for(i=0;i<n-1;i++) { // carga inicial vi[i][0]=v[i] ; vi[i][1]=v[i+1] ; ch[i]=0; } for(i=0;i<n-1;i++) { punt=strstr(v,vi[i]); if(punt!=NULL) { ch[punt-v]++; } } for(i=0;i<n-1;i++) { if(ch[i]>maxt) { maxt=ch[i]; ind=i; } } strcpy(vc,vi[ind]); strcpy(vp,v); punt=strstr(v,vi[ind]); i=0; strcpy(vf,vi[ind]); if (maxt!=0) { while(1) { b=1; punt=strstr(v,vf); chr[0]=punt[2+l]; strcat(vf,chr); k=2+l; k++; l++; if(l==strlen(punt))break; max2=0; strcpy(vp,v); while(1) { punt=strstr(vp,vf); if(punt!=NULL) { j=strlen(punt); for(i=0;i<j-1;i++) { vp[i]=punt[i+1]; } vp[i]='\0'; max2++; if (max2>=maxt) { maxt=max2; strcpy(vc,vf); b=0; } } if(punt==NULL)break; } if(b==3) break; } } cout<<vc; }} | | Problem 1392. Dreaming of Stars has been rejudged | Vladimir Yakovlev (USU) | 1392. Тяга к звёздам | 26 июл 2013 21:06 | 1 | New tests were added to the problem. First tests were replaced with examples from the problem statements. 106 authors have lost AC after the rejudge. | | Getting WA #7 | paarth | 1297. Палиндромы | 26 июл 2013 12:01 | 5 | I have used manacher'a algorithm and tried all the test cases discussed in these discussions and getting correct solution.... I have used manacher for even and odd palindromes separately and found the longest and if longest comes again... as in the same length..take the smaller start.. but now,... I got WA #7 ...I initially faced some problem in compilation too..please suggest some test case P.S. : m doing while(getline(cin,string)) and also tried while(cin>>string) is something to be done here...please suggest Got AC...small error in code: basically typo :D It's just bruteforce task. if string is like : abcdef you can tranform it like: ^#a#b#c#d#e#f#$ so,even and odd palindromes all is transformed like odd palindromes. | | WA test#8 | R. Dubinin | 1493. В одном шаге от счастья | 25 июл 2013 14:00 | 3 | What in test #8? Edited by author 25.07.2013 00:58 Admins, give me some tests, please. i am understand!! need to write std::scanf("%d", &a); insteadd of std::scanf("%i", &a); | | I found the reason for me WA on 13# | fytain | 1039. Юбилейная вечеринка | 25 июл 2013 09:50 | 1 | my method is DP: //invite int sum = 0; for (Integer c : guest.children) { sum += DP[c.intValue()][0]; } DP[index][1] = sum + RATE[index]; // do not invite sum = 0; for (Integer c : guest.children) { int max = Math.max(DP[c.intValue()][0], DP[c.intValue()][1]); sum += max; } DP[index][0] = sum; at first, I got WA on 13#, DP the tree should from leaf to root, but at first I sort the guests by its children count, the right way is sort the guests by depth Edited by author 25.07.2013 09:50 | | error in test#9 | Cawa222 | 1639. Шоколад 2 | 25 июл 2013 00:45 | 1 | #include <iostream> #include <math.h> using namespace std; void main(void) { int a,b,c; cin>>a>>b; c=0; c=a/2+a%2+b/2+b%2;
if (((a==1)&&(b!=1))||((a!=1)&&(b==1))) { c=c-1; } if (c%2) cout <<"[:=[first]" ; else cout <<"[second]=:]" ;
} whot is wrong? Edited by author 25.07.2013 00:45 | | Please give test 2 | Alexander Im | 1200. Рога и копыта | 24 июл 2013 20:23 | 2 | Please give test 2 for this problem. I don't know test#2. But I think that I know hint. Try this: 5 -5 20 Answer: 6.00 2 0 | | Can i use Greedy ? | Lifanov | 1389. Дорожные работы | 24 июл 2013 17:15 | 5 | I take the list (any City with 1 road) and delete this road, then going to connected city and mark all road from it as non-delete, then i going to near city and repeat first step. For example 5 4 1 2 2 3 3 4 3 5 Start with 1 City, delete (1 2) then go in 3 city, and remove (3 4) or (3 5)? Why WA2 ? Sorry fo my English. here is example: 8 7 1 2 2 3 3 4 3 5 4 7 7 8 5 6 Answer depends on the way you go from city 3. Yes. But your algorithm probably realy work wrong. My greedy: While graph is not empty 1. We choose any vertex v: deg(v)=1 (e=(v,u)) 2. Add to the answer edge e. 3. Delete v and u with all its edges from the graph. @Burunduk1 I used the same greedy algorithm as u did but I get WA#2, can u please help me? Edited by author 24.07.2013 17:16 | | why wrong ? i can't understand... | snowmen | 1787. Поворот на МЕГУ | 24 июл 2013 05:37 | 1 | while(scanf("%d%d",&able,&mytime)!=EOF) { sum=0; while(mytime--) { scanf("%d",&temp); sum+=(temp-able); } if(sum<=0) printf("%d\n",0); else printf("%d\n",sum); } | | WA#7? Why? | Prosto Misha | 1089. Проверка со словарём | 24 июл 2013 00:25 | 2 | Please give me test. Thank you! In the example test, please add the following three lines and give a try. "bbout to say" "countxy" should be "big' | | incorrect test # 4 | ₰ҟᾷѓßὂνṑγ (ONPU) | 1089. Проверка со словарём | 24 июл 2013 00:22 | 3 | it seems like test#4 includes big latin letters, but it's impossible according problem statement "все слова записаны в нижнем регистре, слово может содержать только латинские буквы от 'a' до 'z' (то есть «one-seventh» — это два слова — «one» и «seventh»)." admin, please check Requires to split the line into sequence of words, where word could be alphabet word or non-alphabet word. e.g., input: it ockupies ebout one-seventh of the earth's surfase. output: it[ ]ockupies[ ]ebout[ ]one[-]seventh[ ]of[ ]the[ ]earth[']s[ ]surfase[.] each bracketed word is non-alphabet and others are alphabet words. Edited by author 24.07.2013 00:23 Edited by author 24.07.2013 00:23 | | test case | Arsen Babakhanyan (AUA) | 1017. Лестницы | 23 июл 2013 21:12 | 1 | test case Arsen Babakhanyan (AUA) 23 июл 2013 21:12 | | wa18,can someone give some test data? | ateow | 1169. Pairs | 23 июл 2013 21:07 | 1 | | | WA... I may be wrong to pass parameters to the function qsort? | viktorius | 1100. Таблица результатов | 23 июл 2013 14:47 | 2 | #include<stdio.h> #include<stdlib.h> int compare(const void *a, const void *b) { if(*(*(int**)a+1)<*(*(int**)b+1)) return 1; else return -1; } int main() { int n,i,**arr; scanf("%d",&n); arr=(int**)calloc(n,sizeof(int*)); for(i=0;i<n;i++) { arr[i]=(int*)calloc(2,sizeof(int)); scanf("%d %d",&arr[i][0],&arr[i][1]); } qsort(arr,n,4,compare); for(i=0;i<n;i++) { printf("%d %d\n",arr[i][0],arr[i][1]); free(arr[i]); } free(arr); return 0; } Reread the condition. You must output the same results table as bubble sort, but faster. Qsort gives other result. Test output: Yuor output: 3 5 3 5 26 4 26 4 22 4 22 4 16 3 20 3 20 3 16 3 1 2 11 2 11 2 1 2 7 1 7 1 WA Edited by author 23.07.2013 14:47 | | A very strange thing (may be WA#9 skip) | Neznakomec | 1257. Переносы | 23 июл 2013 03:13 | 1 | A bug or feature the situation that last <ENTER> does not count as an error?? For example on test " 12 un-usual for-ced re-al sum-mer N-ED home-work sec-ret ho-lidays Wi-zard th-Er L-so Holi-days Harry Potter was a highly unusual boy in many ways. For one thing, he hated the summer holidays more than any other time of year. For another, he really wanted to do his homework but was forced to do it in secret, in the dead of night. And he also happened to be a wizard. " my program gives away " Harry Potter was a highly unusual boy in many ways. For one thing, he hated the summer holi- days more than any other time of year. For another, he really wanted to do his homework but was for- ced to do it in secret, in the dead of night. And he al- so happened to be a wizard.<ENTER> " (All the attention on line carry after "wizard.") I've done it to pass WA#9, cause understood that output: " " (nothing) on input like " <ENTER> " not good... Edited by author 23.07.2013 03:14 Edited by author 23.07.2013 03:14 | | Hint on Java | the-little-worker | 1656. Войско Тридевятого царства | 22 июл 2013 18:03 | 1 | import java.util.*; import java.io.*; public class p1656 { public static int reverse(int k, int N) { return N - k - 1; } public static point fun(int i, int j, int N, int function) { point p = new point(); if (function == 1) { if (i != j) { p.i = reverse(j, N); p.j = reverse(i, N); } else { p.i = reverse(i, N); p.j = j; } } else if (function == 2) { if (i != j) { p.i = j; p.j = i; } else { p.i = i; p.j = reverse(j, N); } } else if (function == 3) { if (i != j) { p.i = reverse(i, N); p.j = reverse(j, N); } else { p.i = reverse(i, N); p.j = reverse(j, N); } } return p; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int arr[] = new int[N * N]; //{198, 186, 181, 190, 194, 194, 174, 188, 171, 198, 182, 171, 175, 184, 177, 200, 189, 185, 177, 171, 172, 180, 186, 188, 197}; int[] out = new int[N * N]; for (int i = 0; i < N * N; i++) { arr[i] = in.nextInt(); } Arrays.sort(arr); /*for (int i = 0; i < N * N; i++) System.out.print(arr[i] + " "); System.out.println()*/; int po = 0; for (int j = 0; j < N / 2 ; j++) { for (int i = j; i < N / 2 + 1; i++) { // System.out.println("i = " + i + " j = " + j + " po = " + po); out[N * i + j] = arr[po++]; point p = fun(i, j, N, 1); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 2); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 3); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; if (i != j && i != N / 2 ) { int savei = i; i = reverse(i, N);
// System.out.println("i = " + i + " j = " + j + " po = " + po); out[N * i + j] = arr[po++]; p = fun(i, j, N, 1); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 2); // System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 3); // System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; i = savei; }
} } out[N / 2 * N + N / 2] = arr[po++]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) System.out.format("%4d", out[i * N + j]); System.out.println(); } } } class point { int i, j; } | | Is this problem solvable without precalculation? (-) | 2rf | 1946. Китайский хоккей 3 | 21 июл 2013 21:12 | 2 | | | Little question | 2rf | 1479. Контроль по расписанию | 21 июл 2013 16:25 | 2 | If the test is: 4 6 1 2 1 3 1 4 2 3 2 4 3 4 then all created routes are as follows: 1 - 2 - 3 - 1 1 - 2 - 4 - 1 1 - 3 - 4 - 1 2 - 3 - 4 - 2 1 - 2 - 3 - 4 - 1 1 - 2 - 4 - 3 - 1 1 - 3 - 2 - 4 - 1 Am I right? Indeed I was right, the answer for this test is 6. Can this problem be solved faster than in O(2^n * n^3)? | | WA test 4 help me, please! | Abdulaziz | 1581. Работа в команде | 21 июл 2013 15:01 | 2 | #include <iostream> using namespace std; int main() { int n, i, j; cin>>n; int a[n], s=0, s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0, s10=0; for(i=1; i<=n; i++) cin>>a[i]; for(i=1; i<=n; i++) { if(a[i]==1) s1++; if(a[i]==2) s2++; if(a[i]==3) s3++; if(a[i]==4) s4++; if(a[i]==5) s5++; if(a[i]==6) s6++; if(a[i]==7) s7++; if(a[i]==8) s8++; if(a[i]==9) s9++; if(a[i]==10) s10++; //if(a[i]==0) s++;
} if(s1==0) cout<<""; else cout<<s1<<" "<<"1 "; if(s2==0) cout<<""; else cout<<s2<<" "<<"2 "; if(s3==0) cout<<""; else cout<<s3<<" "<<"3 "; if(s4==0) cout<<""; else cout<<s4<<" "<<"4 "; if(s5==0) cout<<""; else cout<<s5<<" "<<"5 "; if(s6==0) cout<<""; else cout<<s6<<" "<<"6 "; if(s7==0) cout<<""; else cout<<s7<<" "<<"7 "; if(s8==0) cout<<""; else cout<<s8<<" "<<"8 "; if(s9==0) cout<<""; else cout<<s9<<" "<<"9 "; if(s10==0) cout<<""; else cout<<s10<<" "<<"10 "; cout<<endl; "<<s8<<" 8 "<<s9<<" 9 "<<s10<<" 10 "; } твоя прога не пройдет тест 1 1 2 2 2 1 1 1 |
|
|