| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| What is s "substring" here? | Vedernikoff Sergey | 1590. Шифр Бэкона | 27 окт 2010 16:20 | 6 |
Is empty string is a substring of the whole string? Is whole string is a substring of the whole string? You can see example: "aaba": a b aa ab ba aab aba aaba Totaly 8 substrings. So, empty string is not substring. Where is baa? "baa" is not subsequnce of "aaba" |
| WA11 ?? | tester | 1136. Парламент | 27 окт 2010 15:51 | 4 |
Here's my code. It gets WA11. Algo: the rightmost number of the current subarray[i..j] is a root of a subtree. The left branch includes those and only those numbers which are less than root; right branch - numbers greater than root. So if we swap these branches in our array and process them recursively we'll get the desired answer. Example: 1 7 5 (left br.) 21 22 27 25 20 (right br.) 10 (root) 1 (lb) 7 (rb) 5 (rt) empty (lb) 21 22 27 25 (rb) 20 (rt) 21 22 (lb) 27 (rb) 25 (rt) 21 (lb) empty (rb) 22 (rt) result: 27 21 22 25 20 7 1 5 10 proc "tree" does all the work. del is the delimiter of the branches. I've used the most primitive algo to swap the subarrays to simplify the solution.
program parliament; {$APPTYPE CONSOLE} var n,i:integer; a,t:array[1..100000] of integer; procedure tree(i,j:integer); var q,del:integer; begin if j>=i then begin del:=j-1; while (del>=i) and (a[del]>a[j]) do dec(del); for q:=del+1 to j-1 do t[q+i-del-1]:=a[q]; for q:=i to del do t[q+j-1-del]:=a[q]; for q:=i to j-1 do a[q]:=t[q]; tree(i,j-del-1); tree(j-del,j-1); end; end; begin fillchar(t,sizeof(t),0); read(n); for i:=1 to n do read(a[i]); tree(1,n); for i:=1 to n do write(a[i],' '); end. So, I also have WA11! What is wrong? I cant understand... {$APPTYPE CONSOLE} type Tchild=record a,b:word; end; var n,i:longint; ar:array[1..4000] of word; ch:array[1..4000] of Tchild; procedure write0; var child,oc:longint; begin child:=1; oc:=1; while (ch[child].a<>0)or(ch[child].b<>0) do begin oc:=child; if ch[child].b<>0 then child:=ch[child].b else child:=ch[child].a; end; if ch[oc].a=child then ch[oc].a:=0; if ch[oc].b=child then ch[oc].b:=0; write(ar[child],' '); ar[child]:=0; end; procedure write1; var child,oc:longint; begin child:=1; oc:=1; while (ch[child].a<>0)or(ch[child].b<>0) do begin oc:=child; if ch[child].a<>0 then child:=ch[child].a else child:=ch[child].b; end; if ch[oc].a=child then ch[oc].a:=0; if ch[oc].b=child then ch[oc].b:=0; write(ar[child],' '); ar[child]:=0; end; procedure swap(var a,b:word); var w:word; begin w:=a; a:=b; b:=w; end; procedure getplace(x,i:longint); var old,p,child:longint; begin p:=1; while true do begin if (x>ar[p])and(ch[p].b=0) then begin ch[p].b:=i; exit; end; if (x<ar[p])and(ch[p].a=0) then begin ch[p].a:=i; exit; end; if (x>ar[p]) then begin p:=ch[p].b; continue; end; if (x<ar[p]) then begin p:=ch[p].a; continue; end; end; end; begin fillchar(ch,sizeof(ch),0); readln(n); for i:=1 to n do read(ar[i]); for i:=1 to n div 2 do swap(ar[i],ar[n-i+1]); for i:=2 to n do getplace(ar[i],i); if n mod 2=1 then begin for i:=1 to n do write0; end else begin for i:=n downto 1 do write(ar[i],' '); end; end. The other realization of the same algo is AC. But where is the mistake here? Why WA???????????????? #define clr(x,y) memset(x,y,sizeof(x)) using namespace std; int a[400000]; int a1[400000],a2[400000]; int s[400000]; int n; bool cmp(int x,int y) { return a[x]<a[y]; } int main(void) { freopen("input.in","r",stdin); freopen("output.out","w",stdout); cin >>n; if (n<1)return 0; for (int i=0;i<n;i++) { scanf("%d",&a[i]); } int k1=0,k2=0; for (int i=0;i<n-1;i++) if (a[n-1]>a[i]) { a1[k1++]=i; } else { a2[k2++]=i; } int t=-1; bool f=0; if (k2!=0) { sort(a2,a2+k2,cmp);
for (int i=k2-2;i>=0;i--) { // cout << a[a2[i+1]]<< " " << a[a2[i]]<<endl; if (a2[i+1]<a2[i]) { if (f) { s[++t]=a2[i+1]; while (t>=0)cout << a[s[t--]]<< " "; }else cout << a[a2[i+1]]<< " "; f=0; } else { s[++t]=a2[i+1]; f=1; } }
s[++t]=a2[0]; while (t>=0)cout << a[s[t--]]<< " "; } t=-1; f=0; if (k1!=0) { sort(a1,a1+k1,cmp); for (int i=k1-2;i>=0;i--) { // cout << a[a2[i+1]]<< " " << a[a2[i]]<<endl; if (a1[i+1]<a1[i]) { if (f) { s[++t]=a1[i+1]; while (t>=0)cout << a[s[t--]]<< " "; }else cout << a[a1[i+1]]<< " "; f=0; } else { s[++t]=a1[i+1]; f=1; } }
s[++t]=a1[0]; while (t>=0)cout << a[s[t--]]<< " "; } cout << a[n-1]; return 0; } Edited by author 27.10.2010 15:51 |
| How much test case there are? | Morteza Hosseini | 1001. Обратный корень | 27 окт 2010 15:46 | 1 |
How much testcase there are in the input. |
| 1001-wrong answer | holtaf | 1001. Обратный корень | 27 окт 2010 15:19 | 2 |
i've got wrong answer.but why?all works in 100% but i've got a wrong answer Edited by author 28.09.2010 21:28 hi algorithm to 1001: 1.to all test case(1-n) to have "sqrt(x)" 2.print result for test case n to test case 1. sorry,I dont good write engilish. good luck. |
| Please, Help)) | enidiny | | 27 окт 2010 13:09 | 1 |
InFile - d.in OutFile - d.out 1 second 4 MiB find a number that is more than N and sum of numbers=S. C++ |
| Is the size of char array <= 1000? | 72VanVector[SevNTU] | 1258. Бильярд | 27 окт 2010 05:08 | 1 |
I've got AC already. I had WA on 11th test first, but then i changed the size of char array from 1000 to 1001... That changed ny WA on AC!! Guess, the true size of array is 1001 in 11th test case. Can post my solution... |
| Help me please! | Saturn | 1258. Бильярд | 27 окт 2010 04:31 | 3 |
Can you give me some test my program got WA 5 6 3 1 1 5 RB --- ANS: 8.4853 |
| Congratulation, Timus! 50000 registered authors! | Oleg Strekalovsky [Vologda SPU] | | 27 окт 2010 01:37 | 2 |
50000 ranked authors (who has at least one AC)! There are a lot of accounts without an accepted solution at all. Edited by author 27.10.2010 01:38 |
| Time Limit Exceeded #7 | Anton Papin | 1794. Шедевры мировой архитектуры | 26 окт 2010 23:58 | 2 |
Here is my code: #include <iostream> using namespace std; //long int _wants[200002]; //long int _nums[100001]; long int n; long int *_wants; long int *_nums; int main() { cin>>n; _wants = new long int[2*n]; _nums = new long int[n]; for (long int i=0; i<n; i++) cin>>_wants[i]; for (long int i=0; i<n; i++) { _nums[i]=_wants[i]; _wants[i]-=i+1; _wants[i+n]=_wants[i]-n; } long int _max=_wants[0]; long int _pos=1; long int _count=1; for (long int j=0; j<n; j++) { if (_wants[j]>-n) { _count=1; for (long int i=j+1; i<2*n; i++) { if (_wants[i]==_wants[j]) { _wants[i]=-n; _count++; } } _wants[j]=_count; if (j==0) _max=_wants[j]; else if (_wants[j]>_max) { _max=_wants[j]; _pos=j-(_nums[j])+2; } } } if (_pos<=0) _pos+=n; cout<<_pos<<endl; return 0; } My algo is following: we take the input twice, like this: for "4 1 2 3" - "4 1 2 3 4 1 2 3". For each standing in array of meanings we count arr[i]-i . For students standing in a right way to answer counting gives same results. Then we count a number of each difference in our array of 2*n elements, but only for meanings in left half of arr (and write it to the beginning of the arr). After that we will have the length of the longest sequence and its beginning position. There's no problem to say who must be first. I found out that for n=99999 there's a TL. But why? This algo is enough fast... Edited by author 25.10.2010 13:15 your program do O(n^2) operation (you have two embedded loop) |
| What to do at 1005? | enidiny | 1005. Куча камней | 26 окт 2010 18:11 | 1 |
I'm a noob) i'm learning pascal. Question at the topic name? |
| hi | Mehran.R | | 26 окт 2010 13:24 | 1 |
hi Mehran.R 26 окт 2010 13:24 what is "Crash (access violation)"? help me plz |
| At last I solved this one!!!! | Tigran92[RAU] | 1306. Медиана последовательности | 25 окт 2010 23:41 | 1 |
|
| WA7 | Paval Marius | 1742. Тим-билдинг | 25 окт 2010 18:01 | 1 |
WA7 Paval Marius 25 окт 2010 18:01 Can I have a sample input that would pass test 7? thanks |
| 10 lines,got AC :D | hoan | 1011. Кондукторы | 25 окт 2010 14:23 | 2 |
#include <cstdio> void main (){ int res= 0, a1, a2; double p, q; scanf ("%lf%lf", &p, &q); do{ res ++,a1= (int)(p* (double)res)/100, a2= (int)(q* (double)res-(1e-7))/100; }while (a1== a2); printf ("%d\n", res); } Edited by author 25.10.2010 14:29 Edited by author 25.10.2010 14:29 |
| Wrong Answer at test #1 | ReDAeR | 1001. Обратный корень | 25 окт 2010 13:23 | 6 |
.. Edited by author 13.05.2010 13:55 #include<stdio.h> #include<conio.h> #include<math.h> main() {float a,b,c,d,e,f,g,h; scanf("%f",&e); scanf("%f",&f); scanf("%f",&g); scanf("%f",&h); a=sqrt(e); b=sqrt(f); c=sqrt(g); d=sqrt(h); printf("%.4f\n",d); printf("%.4f\n",c); printf("%.4f\n",b); printf("%.4f\n",a); return 0; } You shold output results for each number of input meanings, not only for 4. Try using while () { } i got wrong answer inproblem 1001. But my input and output are ok. why? #include<stdio.h> #include<conio.h> #include<math.h> int main() {float a,b,c,d,e,t,g,h; scanf("%f",&e); scanf("%f",&t); scanf("%f",&g); scanf("%f",&h); a=sqrt(e); b=sqrt(t); c=sqrt(g); d=sqrt(h); printf("%.4f\n",d); printf("%.4f\n",c); printf("%.4f\n",b); printf("%.4f\n",a); return 0; } |
| To Admins | Ibragim Atadjanov (Tashkent U of IT) | 1407. Раз-два, раз-два | 25 окт 2010 12:51 | 3 |
To Admins Ibragim Atadjanov (Tashkent U of IT) 24 окт 2010 15:19 something wrong with the 1st test or tests Following prog give me ans for all n (1..100) but at first test it gave me TL import java.math.BigInteger; import java.util.Scanner; public class Timus1407 { public static void main(String[] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); String s = "2"; BigInteger two = new BigInteger("2"); for (int i = 2; i <= n; i++) { BigInteger bigInteger = two.pow(i); String tmp = "1" + s; if(new BigInteger(tmp).mod(bigInteger) == BigInteger.ZERO){ s = tmp; } else{ s = "2" + s; if(new BigInteger(s).mod(bigInteger) != BigInteger.ZERO){ for(;;){} } } } System.out.print(s); } } Strange... On my computer it gives nothing except infinite running. You shouldn't compare BigInteger with "==". Use "compareTo" method. Strange but it is not tl in my computer. Its working still. |
| Weak tests | Fyodor Menshikov | 1604. В Стране Дураков | 25 окт 2010 12:34 | 3 |
My AC solution for test 3 1 3 1 answers 2 1 2 2 3 while better answer is 2 1 2 3 2 |
| Week Test Cases ... | wildCoder | 1774. Парикмахер армии магов | 25 окт 2010 12:16 | 6 |
Hi ,.... A Greedy Algorithm Gets AC but it is Wrong ... for example for this Test Case The AC code says No 5 2 1 2 1 3 2 3 4 2 4 2 Hi I think it is better to add some more test cases to run out wrong algorithms insteat of this few tests that authors say. You are right. The problem will be investigated. Some anti-greedy tests were added. Problem was rejudged (submits from the online contest were not rejudged). We apologize to all authors who solved this problem using greedy algorithm and got wrong AC verdict because of weak tests. Why submits from online contest were not rejudged? I think, it's better to rejudge all submits. But final standings from online contest must not be changed. At current moment it is impossible (technically) to rejudge online contest without changing final standings. |
| 2 admins : Minor typo in russian statement | 2rf | 1776. Праздничный фейерверк | 25 окт 2010 02:39 | 2 |
|
| Weak tests | Sergey Lazarev (MSU Tashkent) | 1724. Тайна происхождения человека | 24 окт 2010 21:48 | 6 |
Weak tests Sergey Lazarev (MSU Tashkent) 31 окт 2009 23:28 My AC program gives answer "1" to the test: GTACcAaa 1 1 8 I think so, as there is no "t" to pair with the "T" in the input string. Could you explain me how did you solve this one? My RMQ solution gives WA in test case 41. Why? My program is incorrect. It gives wrong answers on the test above and on many other tests. It's strange that I've got AC. But test 41 contains something like this: AGgTta 1 1 6 Right answer is "1". I aswered "i think so" trying to say that "your program is incorrect indeed". Sorry. Your code AC is strange for me too. BTW, really thanks for the test 41 tip. I finally got my AC. |