Common BoardHow to solve this problem?I use trie tree and get MLE #2!!!!!!!!!!! Edited by author 26.08.2012 09:02 Edited by author 26.08.2012 09:02 I use suffix array and get AC WHY? type hlist=^list; list=record data: longint; l,r: hlist; end; var n,i:longint; a:array[1..3000] of longint; head: hlist; procedure add(var v:hlist; x:longint); begin if v=nil then begin new(v); v^.data:=x; end else if x>v^.data then add(v^.r, x) else add(v^.l, x); end; procedure draw(var v:hlist); begin if not (v=nil) then begin draw(v^.r); draw(v^.l); write(v^.data,' '); dispose(v); end; end; begin readln(n); for i:=n downto 1 do read(a[i]); for i:=1 to n do add(head, a[i]); draw(head); end. The same error! I don't understand why and what does mean acess violation? Help, please! program p1136; type arbore=^nod; nod=record info:word; left,right:arbore; end; var t,r,q:arbore; n,i:integer; a:array [1..3000] of word; procedure postordine(t:arbore); begin if t<>nil then begin postordine(t^.right); postordine(t^.left); write(t^.info,' '); end; end; begin readln(n); for i:=n downto 1 do read(a[i]); new(t);new(q);new(r);t^.info:=a[1]; for i:=2 to n do begin r:=t; while q<>nil do begin if a[i]>r^.info then begin new(q);q:=r^.right;end else begin new(q);q:=r^.left;end; if q<>nil then r:=q; end; new(q);q^.info:=a[i]; if r^.info<a[i] then r^.right:=q else r^.left:=q; end; postordine(t); end. Should there be a teddy Hater in team of Holden? Edited by author 31.10.2012 15:36 yes, if Holden is no Hater. Could you give me case for test 14? Thank you! each window light travels in both directions, or one? 1 2 0 2 Is answer of second child to himself means "circle" ? This test is incorrect. If a child says that he is innocent then mother write down number 0 for his answer. So test could look as follows: 1 2 0 0 Certainly, answer is NO Edited by author 01.11.2012 14:44 Edited by author 01.11.2012 14:45 Please, give some testdata This is my code: program num_1510; type ar = array of longint; var N,i,j,c,a:longint; arr,arr2,arr3:ar; pow:boolean; BEGIN read(N); setlength(arr,N+2); setlength(arr2,N+2); setlength(arr3,N+2); for i:=1 to N do read(arr[i]); arr2[1]:=arr[1]; c:=1; for i:=1 to N do begin for j:=1 to N do begin if arr2[j]=arr[i] then begin pow:=false; break; end else begin pow:=true; end; end; if pow then begin arr2[c]:=arr[i]; c:=c+1; end; end; for i:=1 to N do begin for j:=1 to N do begin if arr[i]=arr2[j] then c:=j; end; arr3[c]:=arr3[c]+1; end; a:=arr3[1]; for i:=1 to N do begin if a>arr3[i+1] then a:=a else a:=arr3[i+1]; end; for i:=1 to N do begin if a = arr3[i] then begin a:=i; break; end; end; write(arr2[a]); END. Please, help me:) Edited by author 01.11.2012 00:53 var a,b,c,d:integer; begin read(a,b,c,d); if ((a-b=0)or(a-c=0)or(a-d=0)) and((b-a=0)or(b-c=0)or(b-d=0)) and((c-a=0)or(c-b=0)or(c-d=0)) and((d-a=0)or(d-b=0)or(d-c=0)) then writeln('yes') else writeln('no'); end. Test#11 4 10 4 2497 Out - 10 10 10 2 What's wrong? Help!!! I think the res is : 10 10 10 10 Don't use int. Use long long. Edited by author 31.10.2012 15:46 My program got Crash (assert), cause this test has some trash in the end. Валят первым тестом, вроде работает #include <stdio.h> void main() { int i=0,cash=0; char text[1000]; gets(text); while(text[i]!=NULL && i<1001) { if (text[i]=='a' || text[i]=='d' || text[i]=='g' || text[i]=='j' || text[i]=='m' || text[i]=='p' || text[i]=='s' || text[i]=='v' || text[i]=='y' || text[i]=='.' || text[i]==' ') cash+=1; if (text[i]=='b' || text[i]=='e' || text[i]=='h' || text[i]=='k' || text[i]=='n' || text[i]=='q' || text[i]=='t' || text[i]=='w' || text[i]=='z' || text[i]==',') cash+=2; if (text[i]=='c' || text[i]=='f' || text[i]=='i' || text[i]=='l' || text[i]=='o' || text[i]=='r' || text[i]=='u' || text[i]=='x' || text[i]=='!' ) cash+=3; i++; } printf("%d",cash); } Edited by author 30.10.2012 18:58 Поясните пример, пожалуйста Холден - не Hater. Holden is no hater тогда посмотрим на отряды с его участием: look at the companies with Holden. 1.1 2 3 2.1 2 4 3.1 2 5 4.1 2 6 5.1 3 4 6.1 3 5 7.1 3 6 8.1 4 5 9.1 4 6 10.1 5 6 всего Hater-ов 4, поэтому даже если задействовать здесь 2х, то останутся двое на следущую группу. A count of Haters is 4. If we use 2 haters in one group then we have other haters to other group #include <iostream> int fow(int n,int m) {int s=1; for(int i=0;i<m;i++) {s=s*n;} return s; } int main() {int x=0,y,m,n; std::cin>>n>>m>>y; for(int i=0;i<m;i++) { if(fow(i,n)%m==y) {std::cout<<i<<' '; x=1;} } if(x==0) std::cout<<"-1"; return 0; } this my solution: #include <iostream> #include <string> #include <stdlib.h> #include <algorithm> using namespace std; int main(){ int bilo; string s; cin>>s; for (int j = 0; j < s.length() - 1; j++){ bilo = 0; for (int i = 0; i < s.length()-1; i++){ if (s[i] != '1') if ((s[i] == s[i+1])){ s[i] = '1'; s[i+1] = '1'; bilo = 1;
if (i < s.length()-1){ rotate(&s[i], &s[i+1], &s[i] + s.length() - i); rotate(&s[i], &s[i+1], &s[i] + s.length() - i); } } } if (bilo = 0) break; }
int i = 0; while (s[i]!='1'){ cout<<s[i]; i++; }
//system("pause"); return 0; } please send me answer on my e-mail: sergeo_91_@mail.ru or write me here. P.S. thank you in advance. i use BFS and can't pass test 8 because MLE help me, please Edited by author 30.10.2012 09:44 В условии почему-то не упоминается что команда сплочённая ещё и когда она состоит из всех людей и при этом эффективная. - Edited by author 28.10.2012 12:52 Edited by author 29.10.2012 20:47 |
|