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 13 есть? Тест 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." 15 isn't it. I have WA15, but on this test my program outputs right answer what is answer for that test 5 -9 4 -8 -6 1 -10 ? Answer is : Impossible! Why? obstacles -8 and -6 prevent you from going to point -9. 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************ input : 15 23 252 33 215 789 1000 123 -125 29 -45 -450 121 -555 -72 120 123 output : 23 113 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/ who could give some testdata to me ?     3  3 9 10 11   result?   Edited by author 05.11.2008 04:11 My program have WA#11, please help? I think that test is incorrect in previous post! I've got AC. Try test like: 1 -1 100 Result:201 1 1 1 -100 Result:1 201 @lian lian that test is wrong,because the problem says,that there exists answer in any ocassion,but in this test you don't have negative values,so you can't count the quantity of moves...       Edited by author 09.07.2010 17:03 3 2003   Edited by author 10.12.2016 18:09 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. Try this: 1 1 -1   ans: 1 3     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. #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(" "); } Please give test number 9. And as much as possible tests. #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; } 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?     Edited by author 02.02.2013 13:33 Please, give some testdata     Edited by author 06.04.2009 19:06 try this 2 999 1000 -1000 the correct answer is 999 2999   Edited by author 21.12.2011 21:02   Edited by author 21.12.2011 21:02 why? Hi Panther.uz,     try this 2 999 1000 -1000 the correct answer is 999 2999   This is correct answer as the exit is at 999 so in positive direction if a person walks 999 he escapes. This explains first answer. If a person walks in reverse he encounters obstruction at 1000. Thus he reverses to origin and proceeds to exit. Total 1000+1000+999=2999. Hope this helps.   Regards Anupam 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. 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; }   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 :( my program works perfectly about all these tests but still have WA on test 7.. for example , what's the output for this test? input: 0 1     Problem statements have been updated. One sentence was missed in English version. Sorry for inconvenience. in first sample, when input is 3 -2 -10 -4 2  then output is 6 2 what is "2" in output? WA at Test 3? why??????!!!! Why in test 1 answer is "6 2"???Correct answer is "4 2" Because He begin walk from 0 to 2 and from 2 to -2 so calculate it and you'll take 6 not 4; -10 ... -4 .. -2 -1 0 1 2   m = 0; from 0 to 1 m = 1; from 1 to 2 m = 2; from 2 to 1 m = 3; from 1 to 0 m = 4; from 0 to -1 m =5; from -1 to -2(exit) m = 6; n = 0; from 0 to -1 n = 1; from 0 to -2 n = 2; answer 6 2 so did you understand? thanks i understand. can you give me some test for problems   Edited by author 20.10.2011 21:19   Edited by author 20.10.2011 21:19  |  
  |