| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| wrong wrong wrong | primumnah@gmail.com | 1209. 1, 10, 100, 1000... | 4 ноя 2012 01:12 | 1 |
Вот такой код. Хочу найти ошибку. Но найти не могу. Для всех перебранных случаев все вычисляется как надо. Не пойму как пройти тест. #include <iostream> using namespace std; int foo(short pos); int main() { long i; short int y; cin>>i; for(int cnt_1 = 0; i > cnt_1; cnt_1++){ cin>>y; cout<<foo(y)<<" "; } } int foo(short int pos) { short int res(1); short int i(0); do { res = res + i; i++; } while(res<pos); if(res != pos) return 0; else return 1; } Какая тут ошибка? |
| why TLE test 7? (c++) | ONPU_sonmc | 1880. Собственные числа Psych Up | 3 ноя 2012 23:16 | 2 |
#include<iostream> #include<vector> #include <cmath> using namespace std; int main() { int n1,n2,n3,x; int sch=0; vector<int>nv1; vector<int>nv2; vector<int>nv3; cin>>n1; for(int i=0; i<n1; i++) { cin>>x; nv1.push_back(x); x=0; } cin>>n2; for(int i=0; i<n2; i++) { cin>>x; nv2.push_back(x); x=0; } cin>>n3; for(int i=0; i<n3; i++) { cin>>x; nv3.push_back(x); x=0; } for(int i=0; i<n1; i++) { for(int j=0; j<n2; j++) { for(int k=0; k<n3; k++) { if((nv1[i]==nv2[j])&&(nv2[j]==nv3[k])) { sch=sch+1;} } } } cout<<sch<<endl;
} Because 64 * 10 ^ 9 is too many operations for 0.5 seconds :) |
| Test Cases | mk_cena | 1203. Научная конференция | 3 ноя 2012 21:51 | 1 |
Please provide more test cases, the one provided is very naive and it passes easily, I get WA on #4, although someone provided it in the discussion and my code passes it. Thanks |
| why wa 13? | tripler | 1745. Ещё Один Ответ | 3 ноя 2012 21:03 | 2 |
same thing. give some tests, please I don't have tests, but my bug was the following: when I sorted sequences, ones with negative balance should be sorted in the symmetrical way with the sequences with positive balance, and I've compared them wrongly. Edited by author 04.11.2012 17:36 |
| Always Wa4, Who can give some tips | Pegasus | 1869. Новогодний круиз | 3 ноя 2012 18:01 | 1 |
|
| Who can explain this problem for me, I can't understand | Pegasus | 1794. Шедевры мировой архитектуры | 3 ноя 2012 16:24 | 1 |
|
| If you get MLE using DP in Java | SubmitRush | 1119. Метро | 3 ноя 2012 03:13 | 2 |
Actually, You can solve this problem with DP[2][N]. (it's a little strict Memory Limit in compare with the other DP problem in Java.) You can solve it using DP[N]. |
| Memory | Arsenal911 (Samara) | 1119. Метро | 3 ноя 2012 03:01 | 4 |
Memory Arsenal911 (Samara) 22 авг 2011 02:08 My solution for a table size of 1000 to 1000 is 4.07 MB of memory. What should I do? You shouldn't use table 1000*1000. It could be solved using table 1000*2 int x[100],y[100],max[100]; I used: bool table[1000][1000]; which is 0,95367431640625 MB. table[i][j] = 1, if the respective quarter can be crossed diagonally, and '0' otherwise. I also used an array a[1001], in which to store the distance, and several auxiliary variables. The total memory used is 1128 KB. |
| hello | Peca | 1586. Трипростые числа | 2 ноя 2012 23:15 | 2 |
hello Peca 21 сен 2012 21:37 The answer I get for 5 is 41616. I do not understand why this is not good. Can anybody tell me the right answer for 5? Thx. |
| Can you give me solution? | bekmyrat | 1493. В одном шаге от счастья | 2 ноя 2012 21:06 | 2 |
Add '1' to the input number and see if it's lucky, i.e. if the sum of the first 3 digits is the same as the sum of the second 3 digits of the newly formed number. Subtract '1' from the input number and check the same. Output 'Yes' if the newly formed number satisfies the condition, and 'No' otherwise. |
| Befor using bfs... | NUUZ_1 | 1930. Машина инженера Ивана | 2 ноя 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. Не все любят плюшевых мишек | 2 ноя 2012 19:23 | 1 |
brute force is 20 lines AC. how long code with formula? |
| many possible sequences | Elena Posea | 1007. Кодовые слова | 2 ноя 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. Сумма | 2 ноя 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. Болотный доктор | 2 ноя 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. Парламент | 2 ноя 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. Не все любят плюшевых мишек | 1 ноя 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. Квадратная страна | 1 ноя 2012 19:28 | 1 |
WA 14 Irina 1 ноя 2012 19:28 Could you give me case for test 14? Thank you! |
| Window light | SHIRINKIN | 1927. Магия и садоводство | 1 ноя 2012 18:23 | 2 |
each window light travels in both directions, or one? |
| what is correct asnwer for... | Eugene | 1211. Круговая порука | 1 ноя 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 |