Show all threads Hide all threads Show all messages Hide all messages | Page 2 | WA 18 | coolhackermasya | 1642. 1D Maze | 17 Oct 2017 19:14 | 2 | WA 18 coolhackermasya 13 Mar 2017 23:06 var b,a,i,c,n,d,an,k,x:integer; // many variables from other programms... dev:boolean; s:string; begin read(k,n); dev:=true; b:=1001; //didn't no about abs if n<0 then x:=-1; if n>0 then x:=1; for i:=1 to k do begin read(a); if (0<a*x) and (a*x<n*x) and dev then begin s:=('Impossible'); dev:=false end; // can't reach the end if abs(a)<b then b:=abs(a); //nearest obsacle to start point end; if dev then // output begin if n>0 then writeln(n,' ',n+b*2); if n<0 then writeln(abs(n)+2*b,' ',abs(n)); end else writeln(s); end. **********Can't understand what's wrong************ Re: WA 18 Daniel Paleyev [SESC] 17 Oct 2017 19:14 input : 15 23 252 33 215 789 1000 123 -125 29 -45 -450 121 -555 -72 120 123 output : 23 113 | WA 18 | coolhackermasya | 1642. 1D Maze | 13 Mar 2017 23:05 | 1 | WA 18 coolhackermasya 13 Mar 2017 23:05 | WA #2. Second test is not correct | Kipsasjaujoj | 1642. 1D Maze | 22 Feb 2016 14:40 | 4 | In the example test: 3 -2 10 -1 2 It's not Impossible. to the right first: 2 + 2 + 1 + 1 + 10 + 10 + 2 (reached -2, got answer) = 28 to the left: 1 + 1 + 2 + 2 + 2 (reached -2, got answer) = 8 answer: 28 8 First time to see such retarded person. You think obstacles are destroyed after turn man. Please show task fragment that proves it. | Please, help me(( WA9 | Vanakals | 1642. 1D Maze | 5 Apr 2014 18:15 | 1 | Please give test number 9. And as much as possible tests. | wa #13 ПОЧЕМУУУУУУУУ | Лерник Казарян | 1642. 1D Maze | 4 Apr 2014 17:37 | 2 | #include<iostream> #include<vector> using namespace std; int main() { int n,x,m=0,k=0,g; cin>>n>>x; vector<int> a(n); if(n==1) { cin>>g; if(g<0&&x>0) { cout<<x<<" "<<-2*g+x; } else if(g>0&&x<0) { cout<<2*g-x<<" "<<-x; } else cout<<"Impossible"; } else { for(int i=0;i<n;i++) { cin>>a[i]; if(a[i]<x&&m==0) m=a[i]; else if(a[i]<x&&a[i]>m&&m!=0) m=a[i]; else if(a[i]>x&&k==0) k=a[i]; else if(a[i]>x&&k!=0&&a[i]<k) k=a[i]; } if(m<0&&k>0) { if(x<0) cout<<2*k-x<<" "<<-x; else cout<<x<<" "<<-2*m+x; } else if(m<0&&k==0&&x>0) { cout<<x<<" "<<2*x-m; } else if(k>0&&m==0&&x<0) { cout<<2*k-x<<" "<<-x; } else cout<<"Impossible"; } return 0; } И у меня так же ((( #include<iostream> #include<vector> using namespace std; int main() { int n,p,c,nmc=-1,nbmc=1;
cin>>n>>p; int *mas=new int [n]; for(int i(0); i<n; i++) cin>>mas[i]; for (c = 0; c < n; ++c) if ( mas[c] < 0 && (nmc == -1 || mas[c] > mas[nmc]) ) nmc = c; for (c = 0; c < n; ++c) if ( mas[c] > 0 && (nbmc == 1 || mas[c] < mas[nbmc]) ) nbmc = c; if(p>0 && n!=1) { if (mas[nbmc]<p) cout<<"Impossible"<<endl; else cout<<p<<' '<<(2*(abs(mas[nmc])))+p<<endl;
} if(p<0 && n!=1) { if(mas[nmc]>p) cout<<"Impossible"<<endl; else cout<<(2*(mas[nbmc]))-p<<' '<<-p<<endl; } if(n==1) for(int i(0); i<n; i++) { if(mas[i]<0&&p>0) { cout<<p<<" "<<-2*(mas[i])+p; } else if(mas[i]>0&&p<0) { cout<<2*(mas[i])-p<<" "<<-p; } else cout<<"Impossible"; } cout<<endl; /*cout<<mas[nmc]<<' '<<mas[nbmc]<<endl;*/ return 0; } | WA #4 | S.Radjabov | 1642. 1D Maze | 15 Jan 2017 02:45 | 2 | WA #4 S.Radjabov 7 Sep 2013 16:28 This is my code: #include <iostream> #include <cmath> using namespace std; int main() { int a[101], n, x, dis1 = 0, dis2 = 0, lb, rb; bool flag = false, flag2 = false;
cin >> n >> x;
if ((x == 0)) flag2 = true; else { if ( n == 0 ) flag = true; }
for ( int i = 0; i < n; i++ ) { cin >> a[i]; if ( (x > 0) && (a[i] < x) && (a[i] > 0) ) flag = true; if ( (x < 0) && (a[i] > x) && (a[i] < 0) ) flag = true; }
if (flag) cout << "Impossible" << endl; else { lb = a[0]; rb = a[0]; for ( int i = 1; i < n; i++ ) { if ( (a[i] > 0) && (a[i] > rb) && (a[i] > x) ) rb = a[i];
if ( (a[i] < 0) && (abs(a[i]) < abs(lb)) && (a[i] < x) ) lb = a[i]; }
if ( x > 0 ) { dis1 = x; dis2 = (int) abs(2*lb) + x; } else { dis1 = 2*rb + (int) abs(x); dis2 = (int) abs(x); }
if (flag2) cout << "0 0" << endl; else cout << dis1 << " " << dis2 << endl; }
system("PAUSE"); return 0; } --------------------------- I can't understand WHY WA#4 Please, help!!! It's too hard code. The real solution is much easier/ | for All of Programmers | Adhambek | 1642. 1D Maze | 16 Jan 2016 23:08 | 7 | Test 3 : input : 5 2 -1 -2 -3 -4 -5 output : 2 4 Test 4 : input : 2 0 1 -5 output : 0 0 Test 5 : input : 15 23 252 33 215 789 1000 123 -125 29 -45 -450 121 -555 -72 120 123 output : 23 113 Test 6 : 0 213 output Impossible Test 7 : input : 8 12 1 2 3 4 5 6 7 8 output : Impossible Test 10 : input : 0 0 output : 0 0 Test 15 : input : 2 12 1000 -1000 output : 12 2012 Тест 4 точно не такой. По условию сказано, что x!=0. Я проверял, во всех тестах x!=0. Тест 10 тоже не такой. Edited by author 28.01.2014 07:04 Edited by author 28.01.2014 07:05 правильно подметил Vitaliy. Еще возможен такой вариант : input : 3 2 0 -2 4 output : Impossible Невозможен, "Все координаты, включая x, не равны нулю" You have an error in tests 4 and 10: "Each coordinate, including x, is non-zero and doesn't exceed 1000 in absolute value." | test | panther.uz | 1642. 1D Maze | 13 Mar 2022 21:42 | 4 | test panther.uz 4 Apr 2013 01:33 what is answer for that test 5 -9 4 -8 -6 1 -10 ? obstacles -8 and -6 prevent you from going to point -9. | wrong test 7 input data | thegriglat | 1642. 1D Maze | 27 Feb 2013 12:52 | 1 | My python 2.6 code: ============ #!/usr/bin/python import sys def getDist(path,pr,pl): global x coord = 0 i = 0 if path == 1: pp = 1 else: pp = -1 while coord != x: if pp == 1: try: bord = pr.pop(0) except: bord = None else: try: bord = pl.pop(0) except: bord = None while coord != bord : coord += pp i += 1 if coord == x: break pp *= -1 return i (n,x) = (int(x) for x in sys.stdin.readline().rstrip().split(" ")) p = [int(j) for j in sys.stdin.readline().split()] p.sort() pr = [] pl = [] for i in xrange(len(p)): if p[i] >= 0: pr.append(p[i]) else: pl.append(p[i]) pl.reverse() dist = 0 if pr == []: pr = [1000] if pl == []: pl = [-1000] if x > max(pr) or x < min(pl): print "Impossible" else: print getDist(1,pr,pl), getDist(-1,pr,pl) =========== Another test's on forum is OK What input data on test 7? | Page 1 | What am I doing wrong? | Jamshid Akhmedov | 1642. 1D Maze | 2 Feb 2013 14:56 | 2 | Edited by author 02.02.2013 13:33 | Access Violation ? (Test 1) | Mickkie | 1642. 1D Maze | 30 May 2015 10:32 | 3 | #include<stdio.h> int n,i,exit,leftob=-1005,rightob=1005,temp; main() { scanf("%d %d",&n,&exit);
for (i=0;i<n;i++) { scanf("%d",&temp); if (temp<rightob && temp>exit) rightob=temp; if (temp>leftob && temp<exit) leftob=temp; }
if (leftob==-1005) leftob=exit; if (rightob==1005) rightob=exit;
if (exit>0) { if (leftob>0) printf("Impossible\n"); else printf("%d %d\n",exit,-2*leftob+exit); } else { if (rightob<0) printf("Impossible\n"); else printf("%d %d\n",2*rightob-exit,-exit); } scanf(" "); } | WA #8 | kilyak | 1642. 1D Maze | 1 Nov 2012 11:14 | 1 | WA #8 kilyak 1 Nov 2012 11:14 Please, give some testdata | what's wrong? on my pc it works right... (Pascal) | jss94 | 1642. 1D Maze | 14 Oct 2012 19:03 | 1 | var n,i,k:byte; x,d,y:integer; m:array[0..100] of integer; begin read(n,x); for i:=1 to n do read(m[i]); k:=0; y:=n; if x<0 then begin for i:=1 to y do begin if (m[i]>x) and (m[i]<0) then begin writeln('Impossible'); k:=k+1;end else begin if m[i]<0 then begin y:=abs(x); end; if m[i]>0 then d:=m[i]; end; if m[i]<d then d:=m[i];end; writeln(d+d+abs(x)); writeln(y); end; if x>0 then begin for i:=1 to n do begin if (m[i]<x) and (m[i]>0) then begin writeln('Impossible'); k:=k+1;end else begin if (m[i]>x) and (m[i]>0) then begin d:=x; writeln(d);end; if m[i]<0 then d:=m[i];end; if (m[i]<0) and (m[i]>d) then d:=m[i]; end; writeln(abs(d)+abs(d)+x); end; end. | WA #13 | Hi4ko | 1642. 1D Maze | 14 Jan 2012 20:54 | 2 | why? #include <iostream> #include <cmath> using namespace std; #define SWAP(A, B) { int t = A; A = B; B = t; } void bubblesort(int *a, int n) { int i, j; for (i = n - 1; i > 0; i--) { for (j = 0; j < i; j++) { if (a[j] > a[j + 1]) SWAP( a[j], a[j + 1] ); } } } int main() { int n,x,ar[100]; cin>>n>>x; for(int i=0;i<n;i++) cin>>ar[i]; bubblesort(ar,n); int j=0; while(ar[j]<0 && j<n-1) ++j; if(ar[j-1]<x && ar[j]>x && n!=1 ) { if(x<0) cout<<2*ar[j]-x<<" "<<0-x; else cout<<x<<" "<<abs(2*ar[j-1])+x; } else if(n==1) { if(ar[0] > x) cout<<2*abs(ar[0])-x<<" "<<-x; else cout<<x<<" "<<2*abs(ar[0])+x; } else cout<<"Impossible"; } I am also get WA#13.I don't understand why. Please help me. My code is #include"iostream" using namespace std; int main() { int x[100]; int n, x0; cin>>n; cin>>x0; if(n==0){cout<<"Impossible"; return 0;} for(int i=0;i<n;i++) cin>>x[i]; if(n==1) { n=2; x[1]=x0; } for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(x[j]<x[i]) { int t=x[i]; x[i]=x[j]; x[j]=t; } int i=0; for(;i<n-1;i++) { if(x0>=x[i]&&x0<=x[i+1]) { if(x[i]<=0&&x[i+1]>=0) { if(x0>0) { cout<<x0<<' '<<x0+abs(2*x[i]); return 0; } else { cout<<2*x[i+1]+abs(x0)<<' '<<abs(x0); return 0; } } } } cout<<"Impossible"; return 0; } | test #7 | Ivan | 1642. 1D Maze | 12 Nov 2011 20:10 | 3 | tell me somebody please what in this test? Don't know what's in this test but try these ones: 2 7 2 -1 > Impossible 2 -7 -6 3 > Impossible 1 1000 -1000 > 1000 3000 1 -1000 1000 > 3000 1000 1 -999 999 > 2997 999 Re: test #7 Giorgi Pataraia [Tbilisi SU] 12 Nov 2011 20:10 :( my program works perfectly about all these tests but still have WA on test 7.. | WA13 help me | Jumabek_Alihonov | 1642. 1D Maze | 22 Oct 2011 15:55 | 1 | | test case | Levan Arabuli [Tbilisi SU] | 1642. 1D Maze | 28 Jul 2011 13:25 | 2 | test case Levan Arabuli [Tbilisi SU] 28 Jul 2011 13:16 1 2 5 ans? right = 2, but left? "It is guaranteed that 1D person will encounter either obstacle or exit point sooner or later regardless of the initial direction." | if you have WA10 | szatkus | 1642. 1D Maze | 7 Dec 2015 13:36 | 6 | Edited by author 05.09.2010 15:36 Edited by author 22.09.2012 19:16 Edited by author 22.09.2012 19:16 Thanks very much... It's really help me. | WA 1 | rodge(Vologda ML) | 1642. 1D Maze | 20 Jan 2010 22:13 | 6 | WA 1 rodge(Vologda ML) 18 Oct 2009 17:11 var a : array[-1000..0] of integer; b : array[0..1000] of integer; n, i, j, k, l, m, u, x : integer; c : array[1..100] of integer; begin read(n, x); k := 0; m := 0; l := 0; u := 0; j := 0; i := 0; for i := 1 to n do begin read(c[i]); if c[i] >= 0 then b[c[i]] := 1 else a[c[i]] := 1; end; if b[0] = 1 then u := 1; if x = 0 then begin k := 0; m := 0; end; if x < 0 then begin for i := x to -1 do begin if a[i] = 1 then begin u := 1; break; end; end; if i = 0 then begin for j := 0 downto x do begin inc(m); end; m := m - 1; repeat inc(k); until b[k] = 1; k := 2 * k + m; end; end; if x > 0 then begin for i := 0 to x do begin if(b[i]) = 1 then begin u := 1; break; end; end; if i = x + 1 then begin for j := 0 to x do begin inc(k); end; k := k - 1; repeat inc(m); dec(l); until a[l] = 1; m := 2 * m + k end; end; if u = 1 then writeln('Impossible') else writeln(k,' ', m); readln; readln; end. my code it is work for different numbers and tests (my tests( but WA 1) plese, who can help me? Re: WA 1 Oleg Strekalovsky aka OSt [Vologda SPU] 18 Oct 2009 18:14 I solved this problem by emulation. I have WA 1 too. Problem was with calculation distance. They some times became negative. When i add function abs() for every places, where was calculation distances - i got AC Edited by author 18.10.2009 18:20 Re: WA 1 rodge(Vologda ML) 8 Nov 2009 13:51 var a : array[-1000..0] of integer; b : array[0..1000] of integer; n, i, j, k, l, m, u, x : integer; c : array[1..100] of integer; begin read(n, x); k := 0; m := 0; l := 0; u := 0; j := 0; i := 0; for i := 1 to n do begin read(c[i]); if c[i] > 0 then b[c[i]] := 1 else a[c[i]] := 1; end; if x < 0 then begin for i := x to -1 do begin if a[i] = 1 then begin u := 1; break; end; end; if i = 0 then begin j := 0; while (k>x) do begin dec(k); end; k := abs(k); while (b[j]<>1) and (abs(j)<1000) do begin inc(m); inc(j); end; m := m * 2 + k; end; end; if x > 0 then begin for i := 0 to x do begin if(b[i]) = 1 then begin u := 1; break; end; end; if i = x + 1 then begin j := 0; while m < x do begin inc(m); end; while (a[j]<>1) and (abs(j)<1000) do begin inc(k); dec(j); end; k := k * 2 + m; end; end; if u = 1 then writeln('Impossible') else begin write(m,' ',k); end; readln;readln; end. correct my solution but WA1 it's very bad ((( who knows test 1? Edited by author 08.11.2009 14:04 Re: WA 1 rodge(Vologda ML) 8 Nov 2009 14:05 all tests is right may be I wrong in output? can somebody help me and sorry for my bad english Re: WA 1 unlucky [Vologda SPU] 8 Nov 2009 15:54 var a : array[-1000..0] of integer; b : array[0..1000] of integer; n, i, j, k, l, m, u, x : integer; c : array[1..100] of integer; begin read(n, x); k := 0; m := 0; l := 0; u := 0; j := 0; i := 0; for i := 1 to n do begin read(c[i]); if c[i] > 0 then b[c[i]] := 1 else a[c[i]] := 1; end; if x < 0 then begin for i := x to -1 do begin if a[i] = 1 then begin u := 1; break; end; end; if i = 0 then begin j := 0; while (k>x) do begin dec(k); end; k := abs(k); while (b[j]<>1) and (abs(j)<1000) do begin inc(m); inc(j); end; m := m * 2 + k; end; end; if x > 0 then begin for i := 0 to x do begin if(b[i]) = 1 then begin u := 1; break; end; end; if i = x + 1 then begin j := 0; while m < x do begin inc(m); end; while (a[j]<>1) and (abs(j)<1000) do begin inc(k); dec(j); end; k := k * 2 + m; end; end; if u = 1 then writeln('Impossible') else begin write(m,' ',k); end; readln;readln; end. correct my solution but WA1 it's very bad ((( who knows test 1? Edited by author 08.11.2009 14:04 Your code is very crazy :) 1. He get wrong answer for demo test 2. if x < 0 then begin for i := x to -1 do begin (*) if a[i] = 1 then begin u := 1; break; end; end; if i = 0 then begin (**) How do you think - it is possible to go get TRUE in condition (**) if cycle condition (**) is that? And the same bug in for i := 0 to x do begin (*) if(b[i]) = 1 then begin u := 1; break; end; end; if i = x + 1 then begin (**) More help only via e-mail. Edited by author 08.11.2009 15:55Re: WA 1 rodge(Vologda ML) 20 Jan 2010 22:13 Thank you ))) I am thinking and rewriting me programm for 10 minutes now ))) and got AC it's amazing ))) | Starting Point | Varun Sharma | 1642. 1D Maze | 28 Apr 2009 16:36 | 2 | Hi, Where does our legendary 1D person starts his journey from ? What are the coordinates of his home / point ? Thanks A citation from condition: "1D person is located at the origin." Origin is the origin of the coordinates. |
|
|