Perhaps #4 is about a test without the back wall. Here come some questions: 1. Should we assume the back wall to be located in the n+1 - th ? 2. It seems that the second scanning is from the back. So the FIRST maximum refers to the one who is leftmost or the rightmost? Test: 15 5 10 12 10 10 12 10 0.01 3 4 5 95 95 96 6 97 97 98 99 99 99 97 99 What is answer? My answer is: Surface found at 4. Bottom found at 5. Channel 1: No object. Channel 2: No object. Why it is not correct? Обменяю задачу на 1932 и 1934 I get AC. Correct answer: Surface found at 4. Bottom found at 5. Channel 1: No search. Channel 2: No search. Why can't you find object in Chan1? maybe at 11? В двух местах "число не превышающие 35" следует заменить на "число, не превышающее 35". In russian ver.: "Если оно больше некоторого уровня (вам его тоже скажут), то считаем, что объект найден. Тогда вам надо будет выдать сигнал наличия объекта и глубину его нахождения" In english ver.: "If a maximal number is equal to or greater than a certain level, which you'll be given, then you report that you have found an object and give us its location." Compare: "больше" and "equal to or greater" Please, fixed this. =) 1. "And you should take into account that someplace before this number in the sequence there must be a number not exceeding 35, otherwise it's not a wall, it's … well, you don't have to know what." Does it need to check? 2.Сan there be objects in the same position? Edited by author 13.07.2012 03:37 It seems there are extra characters in test 6! I use following construction: while (scanf("%d") != EOF)) { //proccess test } to be able to proccess several test from one file. With this construction i got WA6. When i proccessed only one test i got Accepted. Test #6 is fixed. Thank you. It's something awful! There is no bottom in this test. But it does not mean that you should not analyse the channels! You just should think that bottom is n+1! GOOD LUCK! And get AC! Действительно, Accepted. Но в условии ведь не сказано, что если отсутствует задняя стенка, то необходимо проверять объекты. Кривые тесты... const eps=0; var b:array[1..10000] of extended; n,d,s1,e1,s2,e2:integer; l1,l2:extended; a:extended; i,f,back:integer; frontsearch,frontfound,backsearch,backfound:Boolean; procedure SearchForFrontWall; var i:integer; begin i:=0; frontsearch:=false; frontfound:=false; repeat inc(i); frontsearch:=b[i]-35<=eps until (i=n) or frontsearch; if frontsearch then begin repeat inc(i); frontfound:=b[i]-95>=eps until (i=n) or frontfound; if frontfound then begin f:=i; writeln('Surface found at ',f,'.') end end end; procedure SearchForBackWall; var i:integer; begin i:=f; backsearch:=false; backfound:=false; repeat inc(i); backsearch:=b[i]-35<=eps until (i=n) or backsearch; if backsearch then begin if i<f+d-1 then i:=f+d-1; repeat inc(i); backfound:=b[i]-95>=eps until (i=n) or backfound end; if backfound then begin back:=i-f; writeln('Bottom found at ',back,'.') end else begin writeln('No bottom.'); back:=n-f+1 end; end; procedure SearchChannel(num,s,e:integer;l:extended); var i,m:integer; begin if s>=back then writeln('Channel ',num,': No search.') else begin m:=s; if e>=back then e:=back-1; for i:=s+1 to e do if b[i+f]-b[m+f]>eps then m:=i; if b[m+f]-l>eps then writeln('Channel ',num,': Object at ',m,'.') else writeln('Channel ',num,': No object.') end end; begin readln(n,d,s1,e1,l1,s2,e2,l2,a); for i:=1 to n do readln(b[i]); SearchForFrontWall; if frontfound then begin for i:=f+1 to n do b[i]:=b[i]*(1+(i-f)*a); SearchForBackWall; SearchChannel(1,s1,e1,l1); SearchChannel(2,s2,e2,l2) end else writeln('No surface.') end. 8 0 3 6 72 7 7 22 0.008000 97 19 91 66 65 24 52 96 my AC program outputs: Surface found at 8. No bottom. Channel 1: No search. Channel 2: No search. Thanks for the test, but I still can't turn it into AC: if I replace extended with either real or double I get WA #5. And my program evaluates your test case correctly after just one small fix for all those real types! Can someone please help me? If FRONT+D >N, you're in trouble because of "until(i=n)". I had same problem in my C++ solution, but it was WA5 :) #include <stdio.h> int N, D, S1, E1, L1, S2, E2, L2; double A, arr[10001]; int main() { int i, start = 0, end = 0, one, pos1 = 0, pos2 = 0; arr[0] = -1e10; // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d %d %d %d %d %d %d %d %lf", &N, &D, &S1, &E1, &L1, &S2, &E2, &L2, &A); for (i = 1; i <= N; i++) scanf("%lf", &arr[i]); for (i = 1; i <= N; i++) { if (arr[i] <= 35) break; } for (++i; i <= N; i++) { if (arr[i] >= 95) { start = i; break; } } if (start == 0) { printf("No surface.\n"); return 0; } else { printf("Surface found at %d.\n", start); } for (i = start; i <= N; i++) { arr[i] *= 1 + (i - start) * A; }
for (i = start + 1; i <= N; i++) { if (arr[i] <= 35) break; } if (i < start + D) i = start + D; for (; i <= N; i++) { if (arr[i] >= 95) { end = i; break; } } if (end == 0) { printf("No bottom.\n"); end = N; } else { printf("Bottom found at %d.\n", end - start); } S1 += start; E1 += start; if (E1 > end) E1 = end; one = 0; for (i = S1; i <= E1; i++) { one = 1; if (arr[i] > arr[pos1]) pos1 = i; } if (one == 0) { printf("Channel 1: No search.\n"); } else { if (arr[pos1] >= L1) printf("Channel 1: Object at %d.\n", pos1 - start); else printf("Channel 1: No object.\n"); } S2 += start; E2 += start; if (E2 > end) E2 = end; one = 0; for (i = S2; i <= E2; i++) { one = 1; if (arr[i] > arr[pos2]) pos2 = i; } if (one == 0) { printf("Channel 2: No search.\n"); } else { if (arr[pos2] >= L2) printf("Channel 2: Object at %d.\n", pos2 - start); else printf("Channel 2: No object.\n"); } return 0; } Object cannot be located on the back wall. I think this should be put to problem statement because it tells that objects cannot be BEHIND the back wall (at least eng. version) #include <stdio.h> #include <stdlib.h> #define infile "1288.in3" #define outfile "1288.ou3" #define maxn 10100 #define zero 1e-6 double a[maxn+1],xs; long n,d,front,back,s[3],e[3],l[3]; FILE *fin=stdin, *fout=stdout; void init() { long i; fscanf(fin,"%ld%ld",&n,&d); for (i=1; i<=2; i++) fscanf(fin,"%ld%ld%ld",&s[i],&e[i],&l[i]); fscanf(fin,"%lf",&xs); for (i=1; i<=n; i++) fscanf(fin,"%lf",&a[i]); fclose(fin); } void find_front_wall() { long i,you=0; for (i=1; i<=n; i++) if (a[i]<=35+zero) you=1; else if ((a[i]>=95-zero)&&(you)) { front=i; return; } fprintf(fout,"No surface.\n"); fclose(fout); exit(0); } void change() { long i; for (i=front+1; i<=n; i++) a[i]=a[i]*(1+(i-front+0.0)*xs); } long find_back_wall() { long i,you=0; if (front+d>n) return 0; for (i=front+1; i<front+d; i++) if (a[i]<=35+zero) you=1; for (i=front+d; i<=n; i++) if (a[i]<=35+zero) you=1; else if ((a[i]>=95-zero)&&(you)) { back=i; return 1; } back=n+1; //special!!! return 0; } long min(long a,long b) { if (a<b) return a; else return b; } void zhao(long sign,long s,long e,long l) { long i,j; if (front+s>back-1) { fprintf(fout,"Channel %ld: No search.\n",sign); return; } s=front+s; e=min(front+e,back-1); j=s; for (i=s; i<=e; i++) if (a[i]>a[j]+zero) j=i; if (a[j]>l-zero) fprintf(fout,"Channel %ld: Object at %ld.\n",sign,j-front); else fprintf(fout,"Channel %ld: No object.\n",sign); } void work() { find_front_wall(); change(); fprintf(fout,"Surface found at %ld.\n",front); if (find_back_wall()) fprintf(fout,"Bottom found at %ld.\n",back-front); else fprintf(fout,"No bottom.\n"); zhao(1,s[1],e[1],l[1]); zhao(2,s[2],e[2],l[2]); fclose(fout); } int main() { init(); work(); return 0; } |
|