| Show all threads Hide all threads Show all messages Hide all messages |
| Befor using bfs... | NUUZ_1 | 1930. Ivan's Car | 2 Nov 2012 19:25 | 3 |
How can I quickly build adjacency matrix befor using bfs for this problem. I have TLE#6,#10,#12 for this problem. Any algorithm please! Adjancency matrix will require 10000^2 elements. It's too many, u won't fit in memory limit. Use adjancency list instead. For example, if you use C++, you can represent it as an array of vectors, where the vector at index i contains numbers of vertices that adjanced to the vertex with number i. for (int i=0; i<N; i++) { int a, b; cin >> a >> b; vect[a].push_back(b); vect[b].push_back(a); } ok, there are vectors. but how insert this vectors to the Deikstra algorithm? |
| About solutions | alexProgrammer | 1929. Teddybears are not for Everyone | 2 Nov 2012 19:23 | 1 |
brute force is 20 lines AC. how long code with formula? |
| many possible sequences | Elena Posea | 1007. Code Words | 2 Nov 2012 14:42 | 1 |
Are there many possible answers? For example in the test example my program gets the answer: 0000 (do nothing) 0111 (insert 1 at the end) 1010 (change the last 1 in 0; I suspect that this 1 was initially a 0 and now, due to the noisy line, it's a 1) 1101 (erase the last 1) the total sum of positions is 20, which is a multiple of 5 = 4 + 1 Did I get something wrong? I not, which solution should I print? And is it possible not to have any solution? |
| Solution in Java | xukien | 1068. Sum | 2 Nov 2012 13:44 | 1 |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class No1068 { public static void main(String[] args) throws Exception { BufferedReader rd=new BufferedReader(new InputStreamReader(System.in)); PrintWriter wr=new PrintWriter(new OutputStreamWriter(System.out)); StringTokenizer line =new StringTokenizer(rd.readLine()); Integer n=Integer.parseInt(line.nextToken());
if (n>0) wr.println((n*(n+1))/2);
else { n=Math.abs(n); wr.println(1-(n*(n+1)/2)); } wr.close(); System.exit(0);
} } |
| How to solve this problem?I use trie tree and get MLE #2!!!!!!!!!!! | caiweiwenjs | 1835. Swamp Doctor | 2 Nov 2012 07:20 | 3 |
How 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 |
| crash acess violation #1 | jet-pilot | 1136. Parliament | 2 Nov 2012 00:22 | 2 |
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. |
| team Holden | SHIRINKIN | 1929. Teddybears are not for Everyone | 1 Nov 2012 23:44 | 2 |
Should there be a teddy Hater in team of Holden? Edited by author 31.10.2012 15:36 yes, if Holden is no Hater. |
| WA 14 | Irina | 1073. Square Country | 1 Nov 2012 19:28 | 1 |
WA 14 Irina 1 Nov 2012 19:28 Could you give me case for test 14? Thank you! |
| Window light | SHIRINKIN | 1927. Herbs and Magic | 1 Nov 2012 18:23 | 2 |
each window light travels in both directions, or one? |
| what is correct asnwer for... | Eugene | 1211. Collective Guarantee | 1 Nov 2012 16:01 | 2 |
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 |
| nu va mai uitati la raspunsuri | tudorfrent | 1924. Four Imps | 1 Nov 2012 14:42 | 1 |
Edited by author 01.11.2012 14:44 Edited by author 01.11.2012 14:45 |
| am solutia | tudorfrent | 1639. Chocolate 2 | 1 Nov 2012 14:37 | 1 |
|
| WA #8 | kilyak | 1642. 1D Maze | 1 Nov 2012 11:14 | 1 |
WA #8 kilyak 1 Nov 2012 11:14 Please, give some testdata |
| I can't understand why compile write me: "Wrong answer" | lomobit | 1510. Order | 1 Nov 2012 00:50 | 1 |
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 |
| How to make it even easier? | Megapolice | A. Toxic Eruption | 31 Oct 2012 21:35 | 1 |
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. |
| Why i got WA#11????? | Rizvanov++ de xXx | 1310. ACM Diagnostics | 31 Oct 2012 18:32 | 4 |
Test#11 4 10 4 2497 Out - 10 10 10 2 What's wrong? I think the res is : 10 10 10 10 |
| WA23 | IgorKoval(from Pskov) | 1927. Herbs and Magic | 31 Oct 2012 15:45 | 1 |
WA23 IgorKoval(from Pskov) 31 Oct 2012 15:45 Don't use int. Use long long. Edited by author 31.10.2012 15:46 |
| Wrong test. | -XraY- | 1318. Logarithm | 30 Oct 2012 19:53 | 1 |
My program got Crash (assert), cause this test has some trash in the end. |
| В чём ошибка? C++ | Evgeniy | 1567. SMS-spam | 30 Oct 2012 18:56 | 1 |
Валят первым тестом, вроде работает #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 |
| Тест из примера | AlexDevyatov | 1929. Teddybears are not for Everyone | 30 Oct 2012 18:32 | 3 |
Поясните пример, пожалуйста Холден - не 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 |