Common BoardPlease do something with TL on java applications. My usual programs gets TL too often. For example, normal solution in 1222 using DP and BigInteger has failed because of this problem. I had to use precalculations, but it's not so clear a normal solutions. I solved it with Python and 4 SLOC in 0.14 First make the sum to determinate MIN and MAX money the teacher wanted to give. Then divide it by the price of one ticket. Do it in this order. Hope I helped! :) read(x,y); readln(e); t:=0; if ((abs (x-sin(sqrt(t)))<=e) and (abs(y-cos(t))<=e)) then begin write('0') ; exit; end; f1:=true; f2:=true; repeat t:=t+e until (abs(sin(sqrt(t))-x)<=e) and (abs(cos(t)-y)<=e) or (t>10e12) ; if t>10e12 then write ('FAIL') else write(t:0:1); Nothing special to get AC, just think a little and write about 20 strings of code. Look what happens when T becomes large. !!!!!!!!!!!!!!!!!!!!!!!!! What interval at you for T? And what step of increase? ?????????????????????????? search(+) little hint repeat t:=t+0.001; until cos(t)-y<0.00001; Where is mistake? read(x,y); readln(e); t:=0; if ((abs (x-sin(sqrt(t)))<=e) and (abs(y-cos(t))<=e)) then begin write('0') ; exit; end; repeat t:=t+e until (abs(sin(sqrt(t))-x)<=e) and (abs(cos(t)-y)<=e) or (t>10e12) ; if t>10e12 then write ('FAIL') else write(t:0:1); program ex; type z=array [1..4002] of longint; var n,n1,n2,i,t,k,s,j,l:longint; a,a1,a2,r:z; begin readln(n); for i:=1 to n do read(a[i]); readln(n1); for i:=1 to n1 do read(a1[i]); readln(n2); for i:=1 to n2 do read(a2[i]); j:=1; i:=1; k:=0; repeat if a1[j]>a[i] then i:=i+1; if a1[j]<a[i] then j:=j+1; if a1[j]=a[i] then begin k:=k+1; r[k]:=a1[j]; j:=j+1; end; until (i>=n) or (j>=n2) ; i:=1; j:=1; s:=0; repeat if r[j]>a2[i] then i:=i+1; if r[j]<a2[i] then j:=j+1; if r[j]=a2[i] then begin s:=s+1; j:=j+1; end; until (i>=n2) or (j>=k) ; write(s); end. Hi I think this Problem is very very Nice Easy to understand Hard 2 solve! i got AC with all theoric methods: [code deleted] Sincrely Aidin_n7 Edited by moderator 20.11.2019 23:24 Change Var n,k :longint; >> i,j,s :longint; m :array[0..9] of longint; And all will be correct! > Change > > Var > n,k :longint; > >> i,j,s :longint; > m :array[0..9] of longint; > > > And all will be correct! When N>100,his answer isn't right,either. DON`T POST YOUR CODE!!! >>Messages should NOT contain source code (especially correct solutions) Edited by author 08.01.2008 14:01 50% have in it forums solutions with AC :) I hate this problem!!! I've been solving it 2 days. And now I'm very tired. :( I do very easy, but have Time Limit excepted :( Aaaa, too much code ) Want a shorter solution, email me ) cebotari.vladislav@gmail.com Send my solutions in Java. And get "Runtime error (non-zero exit code)". I decide to check an already accepted solution. Sent the same solution that was accepted 4 days ago and it returned "Runtime error (non-zero exit code)". What's wrong? Any changes on server for Java in last 4 days? P.S. Even with test problem 1000 from here: http://acm.timus.ru/help.aspx?topic=java Edited by author 08.01.2015 11:52 Edited by author 08.01.2015 15:24Vladimir Yakovlev (USU) Fixed [1] 8 Jan 2015 16:32 Input: "Hello world "Next paragraph" and this works " \par last one \endinput Output: Hello world ``Next paragraph'' and this works \par last one \endinput #include <iostream> #include <vector> #include <cmath> using namespace std; int main() { double n; vector<double> v; int a = 1; while (a==1) { cin >> n; v.push_back(n); if (cin.peek() == '\n') a = 0; }
for (int i = 0; i <= v.size() - 1; i++) { //cout << sqrt(v[v.size() - 1 - i]) << endl; printf("%.4f\n", sqrt(v[v.size() - 1 - i]));
} cout << endl;
} out of type. for ex. 876652098643267843 out of double 8888 --> 16 Edited by author 08.01.2015 10:09 Edited by author 08.01.2015 10:09 n = 0 ? Может такое быть ? tupoi! deleted [] Edited by author 07.01.2015 12:54 I'm repeatedly getting WA in Test#3. I converted all weights to negative and used Bellman-Ford. I also checked if the destination is reachable from the source. Nevertheless, I'm getting WA in the same test case. Could someone give me test case #3? I got WA#1 :( What's wrong bros? =============================================================== static int speakerCount = 0; static void solve() throws IOException { final int N = nextInt(); // graph[i][j] = true: i-th is parent of j-th final boolean[][] graph = new boolean[N + 1][N + 1]; for (int line = 1; line <= N; line++) { int parent = nextInt(); if (parent == 0) { continue; } int child = nextInt(); while (0 < child) { graph[parent][child] = true; child = nextInt(); } } StringBuilder speakerList = new StringBuilder(); final boolean[] visitedNodes = new boolean[N + 1]; while (speakerCount < N) { for (int node = 1; node <= N; node++) { if (!visitedNodes[node]) { visit(node, visitedNodes, speakerList, graph); break; } } } out.println(speakerList.toString().trim()); } private static void visit(int node, boolean[] visitedNodes, StringBuilder speakerList, boolean[][] graph) { // Stop if marked if (visitedNodes[node]) { return; } // Marked visitedNodes[node] = true; // Visit each child for (int child = 1; child < visitedNodes.length; child++) { if (graph[node][child]) { visit(child, visitedNodes, speakerList, graph); } } speakerList.insert(0, node + " "); speakerCount++; } Edited by author 23.05.2014 15:48 I think the problem is that a children could have more than 1 parent - and here you have to check if all of his parents have been printed. If you can't find the solution yourself - write and I will tell you a way. P.S. Other people say that "One of the lines in test 4 has trailing space. This old problem was designed for Pascal/C++, such inputs treated as a bad style nowadays." I don't know what this means, but first check if this is the problem! Edited by author 07.01.2015 04:12 can anyone help me with that? My code: [code deleted] Edited by moderator 20.06.2020 16:24 I solve it in absolutely the same way, I get WA too :( Set max id to 2 000 000 and max members to 65536 - it worked for me. What is the 11th test about? Two my solutions (on pascal and c++) got wa11 and I really don't know why. The limit is said to be MAX 3000 members and MAX id 65535, but with this limits I got Access Violation on 11. I set MAX members to 65536 and MAX id to 2 000 000 and it worked. My code got WA for #27. After checking forever for errors, I edited my comparison for my set so that if two distances are equal, the distance with the bigger key will come first as a last desperation. After submitting this, I got AC. I think this should be stated in the problem statement, because it affects the solutions. For those that don't understand what I'm talking about: Input: 2 1 1 1 1 1 1 (Before) WA 27 Output: 1 (After) AC Output: 2 Your sample is incorrect. Because in the statment: "The segments are ordered by non-decreasing ai, and when ai = aj they are ordered by decreasing length. All segments are distinct." |
|