|
|
Common Board1) Use reccurent formula, but do no recursion, and 2) Use BigInteger for the result Good luck:) 3 arrays [8100*900] of byte O<8100*900*9, DP Edited by author 10.09.2009 18:56 Only one with 0.25 time and 7K memory. Isnt your time complexity O(900*8100*9)? Why when I allocated staticly globaly memory like this char a[10005][10005] = {0}; char d[10005][10005] = {0}; I got MLE 4, but not MLE 1? You can used only: char a[901][8101]; char d[901][8101]; Because 9....9 (100 times) S = 900 and S^2 = 8100 Maybe because of the compiler's optimizations #include <iostream> #include <iomanip> using namespace std; int main() { int n; cin >> n; //create mas[2][n] int **mas=new int *[2]; for (int i=0; i<2; i++) mas[i]=new int [n]; //mas filling int ID,M; for (int i=0; i<n; i++){ cin >> ID >> M; mas[0][i]=ID; mas[1][i]=M; } //sort int nmax; for (int i=0; i<n-1; i++){ nmax=i; for (int j=i+1; j<n; j++) if (mas[1][j]>mas[1][nmax]) nmax=j; swap(mas[1][i],mas[1][nmax]); swap(mas[0][i],mas[0][nmax]); } //output for (int i=0; i<n; i++){ for (int j=0; j<2; j++) cout << mas[j][i] << " " ; cout << endl; } return 0; } Посмотри ещё раз на выходные данные, там не без разницы. Edited by author 23.10.2013 14:06 Но ведь в задаче написано "Строки должны быть отсортированы в порядке убывания M". У меня они отсортированы в порядке убывания M, как и сказано в задаче! 3 3 3 1 out:3 3 1 1 1 out:0 3 1 2 3 out:-1 3 2 2 2 out:7 here it is: 4 1 1 2 1 1 3 2 2 4 3 Your answer can be 1 but it must be 2. ans = 2; Adam kishi olar... Misali elememisen amma test qoyursan foruma??? Bashga vaxt kishilikden danishirsan... Algoritmin de ozun kimi efeldi... sagol From the problem, 'any biparous branch splits up to exactly two new branches' My answer is 2. LOL my AC code failed this test :D For example solution number 4974296 time is 0.75. This solution does not use either Z-function or KMP, just std::string::find. Admins, is it intended solution complexity for this problem or time limit should be decreased to for example 0.5 s? I have tried to solve this problem, using std::find and string, but failed with TL#5. Can you please explain your idea to me? My e-mail is: marqueewinq@gmail.com Вы можете сказать 20-ый тест? First case with circle intersected triangle. #include <stdio.h> #include <math.h>
int main(void) { int N, M, Y; int i; int flag = 0;
scanf("%d %d %d", &N, &M, &Y);
for(i = 0; i < M; ++i) { if(fmod(pow(i, N), M) == Y) { printf("%d ", i); flag = 1; } }
if(flag == 0) { printf("-1"); }
return 0; } var i,j,i1,j1,s:longint; b:record s,num:longint; end; begin readln(i1,j1); if i1>j1 then begin s:=j1; j1:=i1; i1:=s; end; b.s:=1000000; b.num:=1; for i:=j1 downto i1 do begin s:=0; for j:=1 to i div 2 do if i mod j =0 then s:=s+j; if ((b.s/b.num)-(s/i))<0.0001 then begin b.s:=s; b.num:=i; end; if s=1 then begin writeln(i); halt(0); end; end; writeln(b.num); end. >??????????????????????? > >??????????????????????? Oleg I need some hints again! "gluk" is very fanny word) "Circle" generally means «окружность», not «круг». English term for «круг» is actually "disk"/"disc". Don't let Google Translate confuse you on this matter! I get access violation with Test#3 failing ? I can't recreate it with sample input given in problem. Can someone help me with this. Thanks Edited by author 01.09.2012 15:01 Edited by author 01.09.2012 15:01 Consider a failing scenario which is like 3 2 1 0 0 0 1 0 1 1 0 1 2 3 Edited by author 21.10.2013 22:17 kostan3 (kostan3@spaces.ru) No subject 21 Oct 2013 21:21 мой ид решайте задачки мне)) If using DP, it seems that saving the path to minimum value exceeds the MEMORY threshold. How to solve it? How do you solve using DP? I used greedy algorithm and cuz of this I only saved only the optimal path (So, O(N) memory). kostan3@spaces.ru poluchil ? syuda toje skinyte rusyasoft@mail.ru Edited by author 21.10.2013 19:17 Edited by author 21.10.2013 19:17 Give me SOLUTION ,please. Hint for C: Just Store and print. It might get a Memory Limit Exceeded. Then take some special care to avoid MLE. Edited by author 11.04.2006 23:52 it must work, but WA test 1? type elem=record name:string;fuck:string;end; var a:array[1..1000]of elem; n,i:word; begin readln(n); for i:=1 to n do begin readln(a[i].name,a[i].fuck); end; writeln('Slytherin:'); for i:=1 to n do if a[i].fuck='Slytherin' then writeln(a[i].name); writeln(''); writeln('Hufflepuff:'); for i:=1 to n do if a[i].fuck='Hufflepuff' then writeln(a[i].name); writeln(''); writeln('Gryffindor:'); for i:=1 to n do if a[i].fuck='Gryffindor' then writeln(a[i].name); writeln(''); writeln('Ravenclaw:'); for i:=1 to n do if a[i].fuck='Ravenclaw' then writeln(a[i].name); end. 8th line is wrong. (readln(a[i].name,a[i].fuck);) need two line readln(a[i].name); readln(a[i].fuck); Please delete your code. Edited by author 29.12.2006 10:44 1 aaaaaa bbbbb Gryffindor Edited by author 21.10.2013 15:02 give me some tests!!! 4 Ivan Ivanov Gryffindor Mac Go Nagolo Hufflepuff Um Bridge Slytherin Tatiana Henrihovna Grotter Ravenclaw |
|
|