Общий форумMy program gives right answers for all your tests, but I got WA7. Please help. Thank you! > Thank you! It's not 2346241344. Edited by author 27.04.2004 19:09 Can you give me test 3 Edited by author 22.02.2007 17:21 When I submit the program with the comparison function shown below, I get WA 27. But if I use a similar comparison function as bruce described in the other topic, i get AC. What's weird is that both result in the same answer (I assert-ed this), but maybe different permutations. So unless my evaluation function (also shown below) is wrong, the judge does not accept all valid permutations. ll calc() { ll ca=0,cb=0,cc=0; REP(i,n) { ca+=x[i].a; cb=max(ca,cb)+x[i].b; cc=max(cb,cc)+x[i].c; } return cc; } typedef struct cmp2 { bool operator() (const X &x,const X &y) { return min(y.a+y.b,x.b+x.c)>min(x.a+x.b,y.b+y.c); } } cmp2; Edited by author 19.02.2007 05:37 I initially used exactly this function, but I realised that it's not a strict weak ordering: consider the toys 1 0 1, 1 0 2 and 2 0 1 (call them p, q, r). Then p === q (I use === to mean not less than or greater than), p === r, but q < r. Can you tell me exactly how you formulated your function that was based on mine? Even after fixing an I/O problem I'm still getting WA #18 for this. Hmmm, it is indeed not a strict weak ordering. I assumed it was, because http://ace.delos.com/OPEN06anal/mqueue.html says it is. (by the way, you wrote that. I should never trust you :P) Anyway, that does not change the fact that both comparisons I use gave the correct final time (as assert-ed), but only one of the generated orderings is accepted. So either my evaluation function of an ordering is wrong, or the judge is wrong (I also assert-ed that each of the nr's was present in the final ordering, so it can't go wrong because stl assumes it is a strict weak ordering, I think). Finally, my AC solution uses this: typedef struct cmp1 { bool operator() (const X &x,const X &y) { return x.v<y.v; } } cmp1; and REP(i,n) { int p=x[i].a+x[i].b,q=x[i].b+x[i].c; x[i].v=p<q?p:INT_MAX-q; } Yes, it was only during this contest I realised that the original comparator wasn't a strict weak ordering. It appears that test case 18 exceeds the stated bounds on A, B and C, which was causing the problems. I now get AC using your comparison function (which is the same one I was trying during the contest, but I got screwed by the non-C99 printf. I've also been screwed by that strange %I64d, as well as by the absence of <?=, >?=, __typeof and probably several others as well. I carefully wrote my solution to not put any extraneous spaces at the end of the second line and it came back WA #1 every time during the contest. If I now put a space at the end of the line, it comes back as WA #12. Argh! Eight years later and we still don't have C99-compliant compilers. I now get WA #18 but presumably that is a different issue. wrong thread Edited by author 22.02.2007 17:08 ??? again. Confusing that the order of the threads changes if you post a solution in the wrong thread, and then want to correct it by going to the other thread. :) Edited by author 22.02.2007 17:08 Edited by author 22.02.2007 17:10 Please give me some more test cases! <code deleted> Edited by author 20.02.2007 19:37 please give me some test cases WA 7 Please, give me same test. I hava WA on test 7. I fogotten the problem and didn't remember structure of difficult tests.Tne next is random. 20 7 14 87 90 103 106 119 122 127 134 143 150 159 166 183 190 215 222 247 254 303 318 383 414 543 574 895 958 2687 2814 thank you, but I have allready found my mistake. :-) why example 1: 1 1 1 uuuur I think it should be 0!! See problem statment: "If the instruction tells the robot to go outside the room, the robot ignores this instruction." er.... I don't understand what question want to ask!! please give me a example!! Edited by author 21.02.2007 19:00 Let's start from the point (1, 1, 1). After first move we will be at the same point (because we can't go outside the room at point (1, 2, 1)). And so on... After all we will be in the position (1, 1, 1). That is the only possible final position. So answer is 1. Can you please explain why sample input 3 is 13*12*10 or it will solve the task ? You can simply write program to check all possible starting points, so you will see that true answer is :) I have a WA on the test 2. Who nows it, please, help me. My program: var i,j,n,m,x:longint; s:array[1..50,1..50]of string[1]; a:array[1..50,1..50]of integer; procedure redata; begin fillchar(a,sizeof(a),0); readln(n,m); for i:=1 to n do begin for j:=1 to m do read(s[i,j]); readln; end; for i:=1 to n do begin for j:=1 to m do begin read(x); if x mod 2=1 then a[i,j]:=1; end; readln; end; end; procedure zamena; var k,x,y:integer; begin for k:=1 to m do if s[i,k]='W' then s[i,k]:='B' else s[i,k]:='W'; for k:=1 to n do if s[k,j]='W' then s[k,j]:='B' else s[k,j]:='W'; if s[i,j]='W' then s[i,j]:='B' else s[i,j]:='W'; for X:=1 to 50 do for Y:=X to 50 do if frac(sqrt((X*X)+(Y*Y)))=0 then begin if (i-x>0)and(j-y>0) then BEGIN if s[i-x,j-y]='W' then s[i-x,j-y]:='B' else s[i-x,j-y]:='W';END; if (i-y>0)and(j-x>0) then BEGIN if s[i-y,j-x]='W' then s[i-y,j-x]:='B' else s[i-y,j-x]:='W';END; if (i-y>0)and(j+x<=N) then BEGIN if s[i-y,j+x]='W' then s[i-y,j+x]:='B' else s[i-y,j+x]:='W';END; if (i+y<=M)and(j-x>0) then BEGIN if s[i+y,j-x]='W' then s[i+y,j-x]:='B' else s[i+y,j-x]:='W';END; if (i-x>0)and(j+y<=N) then BEGIN if s[i-x,j+y]='W' then s[i-x,j+y]:='B' else s[i-x,j+y]:='W';END; if (i+x<M)and(j-y>0) then BEGIN if s[i+x,j-y]='W' then s[i+x,j-y]:='B' else s[i+x,j-y]:='W';END; if (i+x<=M)and(j+y<=N) then BEGIN if s[i+x,j+y]='W' then s[i+x,j+y]:='B' else s[i+x,j+y]:='W';END; if (i+y<=M)and(j+x<=M) then BEGIN if s[i+y,j+x]='W' then s[i+y,j+x]:='B' else s[i+y,j+x]:='W';END; end; end; procedure main; begin for i:=1 to n do for j:=1 to m do if a[i,j]=1 then zamena; end; procedure outdata; begin for i:=1 to n do begin for j:=1 to m do write(s[i,j]); writeln; end; end; begin redata; main; outdata; end. What does it mean? And why the sample result #1 is 1? #include <iostream.h> #include <stdio.h> #include <string.h> int p[4]={-1,-1,-1,-1}; struct student { char name [256]; }; int getfac(char* fn); int main () { int n,i,j,id; struct student stud[4][1000]; char* fc[4]={"Slytherin","Hufflepuff","Gryffindor","Ravenclaw"}; char tmp1[256]; char tmp2[256]; scanf("%i", &n); for(i=0;i<n;i++) { //scanf("%s\n%s\n",tmp1,tmp2); //printf("%s\t-\t%s",tmp1,tmp2); cin.getline(tmp1,256);
//cout<<tmp1<<endl; cin.getline(tmp2,256); //cout<<tmp2<<endl; id=getfac(tmp2); strcpy(stud[id][p[id]].name,tmp1);
} for(i=0;i<4;i++) { if(p[i]>-1) cout<<fc[i]<<":\n"; for(j=0;j<p[i]+1;j++) { cout<<stud[i][j].name<<"\n"; } cout<<"\n"; } /*char x[256]; cin.getline (x,256); cout<<x<<endl;*/ return 0; } int getfac(char* fn) { if(!strcmp(fn, "Slytherin")) { p[0]++; return 0; } if(!strcmp(fn, "Hufflepuff")) { p[1]++; return 1; } if(!strcmp(fn, "Gryffindor")) { p[2]++; return 2; } if(!strcmp(fn, "Ravenclaw")) { p[3]++; return 3; } return -1; } If A = "010" and B = "010", then A + B = "100" ? Yes? it is correct. (2+2=4) There are two algorithms of determining a bridge in the graph: simple and advanced. Simple algorithm O(n^2) works more than 1s if written in Java, but less than 1s if written in C++. I suggest to lower time limit to 0.5s, after that only advanced solutions O(n), (n=number of islands) will be accepted. My first C++ solution O(n^n) runs about 0.3sec, so i think it's useless to decrease time limit. I got Output Limit on Test#3 This Is My CODE: #include<iostream> using namespace std; char stack[50000][14]; int pos=0; bool ii=true; void push(char a[4],char b[9]) { int i; int l=strlen(a); for(i=0;i<l;i++) stack[pos][i]=a[i]; stack[pos][i]='#'; i++; int ll=l+strlen(b)+1; for(;i<ll;i++) stack[pos][i]=b[i-l-1]; pos++; } void pop(char a[4]) {
int i; int j; for(i=pos-1;i>=0;i--) { ii=true; j=0; if(stack[i][0]!='~') { while(stack[i][j]!='#') { if(a[j]!=stack[i][j]) { ii=false; break; } j++; } j++;
if(ii) { int sl=strlen(stack[i]); for(;j<sl;j++) { cout<<stack[i][j]; } cout<<endl;
stack[i][0]='~'; return; } }
} } int main() { char a[4],b[9]; char tmp[4]; char cc; int n; cin>>n; for(;n>=1;n--) { tmp[0]='~';tmp[1]='~';tmp[2]='~';tmp[3]='~'; cin>>tmp; if(tmp[1]=='U') { cin>>a>>b; push(a,b); } else { cin>>a; pop(a); } }
return 0; } Edited by author 21.02.2007 00:33 Who can explain me how to solve this problem? Firstly try to solve similiar problem in one dimension. Then you will find 3D-answer easily. Good luck! I know how to generalize solution of 1-dimensional problem to case 3d, but i can't solve 1-dimensional problem :) I think it's a "not hard combinatorial task" but I cannot get the sample output on test 3, it think it should be 13*13*10 In one dimension is enough to find final positions of left and right ends of segment only. All coordinats between these positions are achievable. Tell me your email address and i'll send you my AC solution... Edited by author 20.02.2007 21:55 I didn't understand the question!!! exactly what must our output 123<-456<-7890 <<<<<<<<<<<<<<<<to order <<<<<<<<<<<<<<<<<computers and ... task 1014 input output 1 1 0 10 2 2 10 25 test 8: ? ? ?????????????????? Edited by author 20.02.2007 12:41 |
|