|
|
Общий форумI'm getting runtime error(access violation) on test case three. I don't know where I went wrong. Can anyone please help me? Here is my code using namespace std; #include <iostream> #include <cmath> #include<bits/stdc++.h> long long int n,m; bool vi[1005][1005], di[1005][1005]; float dp[1005][1005]; #define inf 1e7 float shortest_path(int x, int y){//returns shortest path //base case if(x==n && y==m) return 0.0; if(x>n || y>m) return inf; //memorization if(vi[x][y]) return dp[x][y]; //recursive relation float a,b,c = 20000.0; if(di[x][y]==1){ a = sqrt(c) + shortest_path(x+1,y+1);//diagonal b = inf; }
else { a = 100.0 + shortest_path(x+1,y);//left b = 100.0 + shortest_path(x,y+1);//up }
float ans = min(a,b); dp[x][y] = ans; vi[x][y] = 1; return dp[x][y]; } int main(){ cin>>n>>m; int k; for (int i = 0; i < n*m; ++i) { for (int j = 0; j < n*m; ++j) { di[i][j] = 0; vi[i][j]=0; dp[i][j]=0; } } cin>>k; for (int i = 0; i < k; ++i) { int a,b; cin>>a>>b; di[a-1][b-1] = 1; } cout<<round(shortest_path(0,0))<<endl;
} check that (r - l) % 2 == 1 Just calculate all possible sums. Then try to find some sum-n in this sums Got it. Never mind. It was simply a 12 digit input which is already prime. :) This problem is quite easy. Easier than a lot of problems with much less rated difficulty. I've already run throw every test i've found here and some that I thpught myself. I dont understand what is test #23. Can someone post some test to run? Edited by author 08.03.2021 04:25 Edited by author 25.03.2021 12:41 hi how is this issue in java programming language. please help /** * @author koti4 * */ import java.util.*; public class Main { /** * @param args */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int k,n,x,y,flag=0; char x1,y1; String s = " "; n=input.nextInt(); for(int q = 0;q<n;q++) { s=input.next(); x1=s.charAt(0); y1=s.charAt(1); x = (int) x1-96; y = (int) y1-48; /*System.out.println(x); System.out.println(y);*/ for(int i =-2;i<=2;i++) { for(int j=-2;j<=2;j++) {
if (j != i) { if(x-i>0 & y-j>0 & x-i < 9 & y-j < 9) { if(i*i+j*j==5) { flag++; } } } } }
System.out.println(flag); flag = 0; } input.close(); } } journ = [] x = 0 k = 0 sold = 0 cmd = ',,' while cmd[0] != 'QUIT': cmd = input().split() oper_name = cmd[0] if cmd[0] == 'BID': x = cmd[1] journ.append(x) elif cmd[0] == 'DEL': x = cmd[1] journ.remove(x) elif cmd[0] == 'SALE': x = cmd[1] k = int(cmd[2]) for i in journ: if float(i) >= float(x): k -= 1 sold += 1 else: continue print(sold * 0.01) What is wrong ? Can I use CompletePack to solve it? Give me a test about wa15. 5 8 a 11 1.1 b 14 1.4 c 15 1.5 e 15 1.5 f 20 2.0 5 8 a 11 1.1 b 14 1.4 c 15 1.5 e 10 1 f 20 2.0 Input: _123 My first solution output: _<span class=number>123</span> My second solution output: _123 But all passed. So which answer are correct? Task description says: "The correct source of a program in Pascal is given" Your input is definitely not correct source .I'm already tired of solving this number..Mods please give me 19th test case... Please, if you know, give an advice, how to pass this problem O(n^3) to calculate dp values. o(1) to answer query. dp[floors][eggs] -- answer. it enough to calculate in O(10*n^2) AC in 0.015sec ограничение по времени для Питона не выполняется... A test like this is possible: 15 0 35 12000000 12000000 -1 First time it occurs in Test 9. This means that you should pay the same tax for any amount of salary. It is ok to output 0.00 for all such tests, despite it is not correct always because of interim roundings of regional coefficient. Everything else is well-described in previous comments, basically correct numbers round and correct searching of initial salary (you should search for max possible value with 2 decimal places in it) are the only things that can make the initial problem description being unclear. Test case 2: 9 -1 1 -2 2 -3 3 -10 10 3 6 4 5 2 7 1 8 0 9 Answer: 6 6 5 7 8 9 4 Test case 3: 100 272 422 352 367 102 435 274 469 532 554 88 468 28 761 334 381 62 236 858 955 104 930 4 892 467 749 39 695 189 709 217 790 571 999 126 355 138 779 570 645 31 222 372 511 345 888 535 731 435 953 87 869 172 863 442 936 450 704 452 697 862 896 887 977 510 844 135 225 95 932 632 888 30 704 165 523 47 306 107 645 22 34 237 712 779 796 505 964 419 495 171 751 449 616 62 642 355 954 101 266 71 585 284 723 69 900 781 998 21 338 619 950 173 239 394 502 183 605 113 999 30 748 122 833 541 829 65 453 650 741 141 562 355 928 360 852 83 997 563 590 482 668 318 980 84 170 233 858 9 484 637 799 104 611 483 856 29 889 16 463 530 709 774 979 414 654 332 527 406 476 257 735 57 257 201 508 259 806 62 955 410 790 37 720 490 893 573 779 241 400 315 640 242 940 165 929 54 814 356 501 Answer: 13 2 8 95 88 38 66 77 48 14 92 61 79 12 the answer to test 3 can also be 13 2 8 95 88 38 66 51 48 14 92 61 7 12 it can also be 13 45 58 22 84 96 52 86 46 19 62 26 79 12 can also be 13 85 58 22 84 96 52 86 46 19 62 11 35 69 Edited by author 03.03.2021 19:41 Edited by author 03.03.2021 19:41 It says we have to start at the lowest left tile. Does that mean that the euclidean distance of the tile from origin should be minimum?? or does it mean that we have to look for left most layer and lowest tile in that?? try this test: label: a = 1 goto label I try to solve this problem as "offline LCA problem" with recursive DFS, but I have TLE? Where is mistake? Maybe if you solved LCA problem effective you can get AC, but there is easier way to solve this problem. u are late he got ac in 31 Jan 2009 P.S. Нашёл баг, из-за которого был WA: если вы в Pascal пишите z:=n*(n-1), где z-int64, n-longint, то результат z будет типом longint; правильно так: z:=n; z:=z*(n-1). И ещё: лучше выводить не 4 знака в ответе, а все. Edited by author 03.08.2016 11:44 thnx a lot Felix_Mate i also face same situation. |
|
|