Общий форум Edited by author 01.06.2014 20:04 my code is running correctly but yet it fails at test 1 :( Can you add Rust language compiler? Edited by author 11.06.2016 16:54 Just a passing note: the same exact code gets TLE in G++ but AC in Visual C++ (with a very comfortable margin). Make sure to test your code in both compilers before making a judgement that your code is too slow, for those who are coding in C/C++. That's ridiculous for some reason. TLE in G++ but AC in Visual C++ without a single edit in the source code. wow, the same one problem Here is my Solution. As this problem is related to stable sort and there is built in stable_sort function in c++ so it has become easier #include <bits/stdc++.h> using namespace std; bool compare( const pair<long long int,long long int>& x, const pair<long long int, long long int>& y ) { return (x.second>y.second); } int main() { vector<pair<long long int,long long int> >a; long long int n,i,j,b,c; cin>>n; for(i=1;i<=n;i++) { cin>>b>>c; a.push_back(pair<long long int,long long int>(b,c)); } stable_sort(a.begin(),a.end(),compare); //must include stable_sort vector<pair<long long int,long long int> >::iterator p; for(p=a.begin();p!=a.end();p++) { cout<<p->first<<" "<<p->second<<endl; } return 0; } Edited by author 11.06.2016 01:55 Whats wrong with my code. I get correct answer for Test 6 on my compiler, but when I submit the solution, I get wrong answer. Please help!! I tried with below values and got correct answer 4 3 3 4 5 Correct answer: 1 #include <iostream> using namespace std; int main() { int a,k,n,d; int b=0; cin>>k>>n>>d; for (int i=0;i<n-1;i++) { cin>>a; a=a-k; b=b+a; } if (d-k>=0) { if (b+d-k>=0) cout<<b+d-k; else cout<<0; }
else if (b>0) cout<<b; else cout<<0; char f; cin>>f; } I have some problem, try 5 4 3 , you must have 0. I used Dijkstra+heap optimized but still got TLE on #11.. Is there some better algorithm? help.. my email:caoyuan@mail.ustc.edu.cn thx. Try to use numbers instead of strings How to cope with the strings? I put all strings to a map, then for each string I construct all possible neighbours and then I check if they are in a map. So I have to deal with 50000 * 135 * 16 = 108 000 000 operations. It is too much. I can use a hash table. However, is there any simpler solution than using the hash table? You can use strings (because it's so conveniently), but you have to forget about std::map. Use unordered_map<string> (or your hash table) instead of it. I had TLE on test 11 with std::map, but when I changed map to unordered_map, I got AC with not bad time. I think it's easier than use numbers instead of strings. What is wrong #include <cstdio> unsigned long int contador[65535]; void carga() { for(int i=0;i<65535;i++) { if(i==0) contador[i] = 1; else contador[i] = contador[i-1] + i; }} bool busqueda(unsigned long int k[], int i) { bool buscador = false; int inf = 0, sup = 65534, centro; while(inf <= sup) { centro = ((sup - inf) / 2) + inf; if(contador[centro] == k[i]) { buscador = true; break; } if(contador[centro] < k[i]) { inf = centro + 1; } if(contador[centro] > k[i]) { sup = centro - 1; }} return buscador; } int main() { carga(); unsigned long int k[65535]; int n, i; scanf("%d", &n); for(int i=0;i<n;i++) { scanf("%lud", &k[i]); } for(i=0;i<n-1;i++) { if(busqueda(k, i)) printf("1 "); else printf("0 "); } if(busqueda(k, i)) printf("1"); else printf("0"); printf("\n"); } i am also getting WA at 5 It was very easy. Backtracking(перебор с возвратом) I think that it is hard problem and has exp(n) complexity. If remove psevdopractic decoration it is to solve a system boolean equation of 100 unknows Xi with type of Xi^Xj=0; (NotXi)^Xj=0;(NotXi)^(NotXj)=0. Amount of equation is near 10000. Thus we have easy problem for weak tests and very hard problem for detailed test. This situation was brightly shoun for identical Ships problems.Programmers should create code working on all possible tests in prescribed range of variables. Now I am also having Ac(0.031) by using backtracking. I have applied this method to boolean problem not to Graf. But I fear that we all will lost our submits if problem will be rejudged. In worst case in complexy is O(n^2) Yes, it's O(N^2). And resembles another problem of this type: 1382 does transitive closure algorithm work here? Just a standard 2-SAT problem. . Edited by author 13.06.2016 15:16 I tried test 1 given in task on my computer and got the same answer. But i get WA #1 wwhen submit try to locate the centre of the diameter of the tree ! O(N) My programm passes all tests from forum, but i still got WA 10. Have anybody some more tricky tests? ADMINSTRATOR HELP PLEASE !!!!!!!!!!!! IT'S MY COD var a:array [1..20010] of char; i,j,k,n,w:integer; r:char; s:string; f:boolean; g:text; t:integer; procedure solve; label 1; var e:integer; begin f:=false; t:=0; for k:=1 to n+i do if (a[k]<>a[n+i-k+1]) then goto 1; f:=true; 1: end; {IMPORTANT PART} Begin assign(g,'input.txt'); reset(g); while not eof(g) do begin readln(g,s); n:=0; for i:=1 to length(s) do begin n:=n+1; a[n]:=s[i]; end; i:=0; repeat solve; if not(f) then begin i:=i+1; for j:=n+i downto n+1 do begin a[j]:=a[j-1]; end; a[n+1]:=a[i]; solve; end; until f; end; // close(g); for j:=1 to n+i do write(a[j]); readln;readln; end. REAL MADRID LUCK THE BEST CLUB Me too!!! program Ural1354; var s:string; a,b,l:longint; begin readln(s); l:=length(s); a:=1; while a<l do begin if s[a]<>s[l] then begin s:=s+' '; for b:=length(s) downto l+2 do s[b]:=s[b-1]; inc(l); s[l]:=s[a]; end; inc(a);dec(l); end; writeln(s); end. You are to find a nonempty word S2 if the input is palindrome... Test#4 abaabaaba ans: abaabaaba //for WA4, because S2 must be not empty! abaabaabaaba //for AC Edited by author 25.11.2011 17:57 I have the same answer, but still get WA4. What the problem? That's not the answer my friend. This is correct: abaabaaba abaababaaba As you see, your solution add three characters. Mine add only two. Greetings! nope, you should print S1 S2, as you see in your answer there is not clearly S1 There are mistake in statement may be. Difference between ._. ._. ..| and ._| is 1 |_. |_. Difference between ._. ._. ..| and |.| is 2 (the second example, the second number) |_. |_| My program write '02:05' except '00:05' like in example and I have wrong answer. Can someone help me? Edited by author 04.06.2016 15:30 Of course only after the end of contest For this task, pay attention to last few sentences. >>Each subsequent value must be strictly less than the preceding one.<< and >>If several answers exist, output any of them. It is guaranteed that there is at least one consistent sequence.<< Thanks a lot! I forgot that 1 test can be not like in statement. And I'll fix my mistake. Edited by author 05.06.2016 15:30 Edited by author 05.06.2016 15:27 Edited by author 07.06.2016 16:45 print(int((((8*int(input())+1)**.5)-1)/2)) why the fuck doesnt it work???? i got wa6, who can help me with tests? Do you know how floating-point numbers work? Hint: use binary search Edited by author 24.10.2014 14:27 10^600 gives "OverflowError: int too large to convert to float" :) You can use Python library "decimal" sort, read from head and tail\ if head+tail>maximum -> add head,tail to the answers (in front),\ otherwise, add head to answers (to the back)\ wow! interesting observation though When Ivan enters a project, *must* he use all the technologies used in the project, or can he choose to use only a subset of them (so as to avoid using a technology he has already used)? Someone said that it can be solved by Greedy. Just use net flow to catch the largest number of "+". And then so. But they all said that it is a wrong arithmetic. Could you tell me your way to solve it? > Someone said that it can be solved by Greedy. Just use net > flow to catch the largest number of "+". And then so. But > they all said that it is a wrong arithmetic. Could you tell > me your way to solve it? > > Someone said that it can be solved by Greedy. Just use net > > flow to catch the largest number of "+". And then so. But > > they all said that it is a wrong arithmetic. Could you > tell > > me your way to solve it? You can't prove it, because there is a counter-eaxample: 2 +---- +---- +---- +---- +---- Could you tell me what's the meaning of this problem?my english is noot good.The google translation is bad. |
|